There is a while that I have this link in my “Linq bookmarks collection” and I think it will be helpfull for beginner and anyone who has forgotten a scrap of Linq syntax or has failed to build a query…
101 Linq Samples
16 02 2010Comments : Leave a Comment »
Tags: Linq Samples
Categories : Linq To Entity, Linq To SQL
Linq to SQL Boolean operation convertion
5 03 2009Another limit when using Linq To SQL is the SQL translation of boolean operation.
For exemple, when writting:
from s in sTable
select new{
BoolValue=BoolValue1&&BoolValue2
}
the corresponding SQL interpretation will be like that:
select BoolValue=case when (BoolValue1 and BoolValue2) then 1
when !(BoolValue1 and BoolValue2) then 0
else NULL end
from sTable
However, the wished result is 1 or 0, not NULL .
Be aware of that when processing boolean operation…
Comments : Leave a Comment »
Categories : Linq To SQL
Linq To SQL : LinqContext per Unit of Work
11 11 2008To implement a Linq To SQL Oriented solution, there are many ways to construct your application. But only one interested me : the Context per Unit of Work Architecture.
When using Linq To SQL, you need to instanciate a Context which contains your entities tables and allow you to apply query methods. But when your application is construct with many layers, you only can pass Context through methods to keep the same context during your business operations. It is the same problem when a transaction is required(managed by Linq To SQL Context though optimistic transaction).
Comments : Leave a Comment »
Tags: Architecture, Linq To SQL, LinqContext
Categories : Architecture, Linq To SQL
Linq To Entity/Entity Framework with SP1
22 10 2008When the Linq word begin to spread to the developper’s world, I immediatly inform me about what is it and what can I do with “that”. After trying Linq To Object, Linq To XML, Linq To SQL and Linq To Entity, I was convinced that it was the right path to follow. But for Data management, I was preferring Linq To SQL because Linq To Entity utilisation was boring(Stored Procedure to write).
After SP1, Linq To Entity was not the same. So I studied it more deeper… And some good things falls.
Comments : Leave a Comment »
Tags: .NET Framework 3.5 SP1, Linq To Entity
Categories : Architecture, Linq To Entity, Linq To SQL
Linq To SQL Generic Controller
20 10 2008With the power of Linq language, it’s easy to use Linq To SQL to build 95% of the data access interrogation.
But you will notify that 2/3 of your data access methods is always the same, as GetById, GetAll, Insert, DeleteById…
So Microsoft staff has written a class named GenericController that allow you to centralize all standard methods in one class. You only need to inherit from it and a good part of your job is done.
http://code.msdn.microsoft.com/multitierlinqtosql
If you look more deeper in this pack, you will find some other classes written to instanciate one LinqContext by Query or a Linq To SQL Debugger(see also my ticket on DebugWriter).
Comments : Leave a Comment »
Tags: DAL, Generic Controller, Linq To SQL
Categories : Architecture, Linq To SQL
View Linq SQL Queries in VS Debug mode
20 10 2008When you begin to write complex Linq To SQL Queries with many IQueryable associations, it must be difficult to catch all the SQL generated parts by Linq To SQL. That’s why, after searching on the web some information, I have found this little class that can be usefull : DebugWriter.
Comments : Leave a Comment »
Tags: Linq to SQL Debug, LinqContext
Categories : Linq, Linq To SQL
Linq Synchronizer
7 10 2008The first time I was using Linq To SQL, I was frustrated by the fact VS2008 did not integrated the more simple fonctionnality called : “Synchronize DBML Shema with Database”. Just removing my classes from DBML Shema and perform a Drag&Drop from Server Explorer to schema was to much for me ^^.
So I wrote a simple VS 2008 plug-in which allow with 2 clics a synchronization between my database and My DBML Schema.
Comments : Leave a Comment »
Tags: Add-Ins, DBML, Linq, Tools
Categories : Add-Ins, Linq To SQL, Visual Studio
Linq To SQL : How to order with a string typed expression ?
23 09 2008After using Linq To SQL queries, I was quickly confronted to sort my data with a string expression provided, for example, by a gridview when a user require it. At this moment, I understood that the strongly typed system used with Linq cannot help me for this task… Understanding the fact that allowing a string expression representing an object property is contrary to Linq purpose, I began to search with our best friend “Google” a soluce to resolve quickly my problem. But the best that I can obtain was a “switch case solution” which, according to the string property name, build the linq query sort filter with the associated object property. Immediatly, I guess my switch case code with 8-10 columns… No…
So, I started to write an extended method “OrderBy” allowing to take a string sort expression. Here the result.
Comments : 7 Comments »
Tags: Extended Method, Linq To SQL
Categories : Linq To SQL, Workarounds
Linq Overview
23 09 2008During my migration from .NET 2.0 to .NET 3.0/3.5, my first tought was : ‘With .NET 3.5, I can used Linq To SQL and stop to bore me with all the code generation tools”. I don’t want to crush the glory of tools like Raptier or Code Smith, but an ORM produce by Microsoft can be better in generation time(class generation and integration) and simplicity. It was true(for common uses). But better than that. Linq offers many others functionalities(strongly typed, composite queries, relashionship between objects and many more). And I began to forget all about others problems when the Graal was not here…
After a month of research, I have started to write a document on my Linq feedback and I share it today 🙂
Comments : 1 Comment »
Tags: Linq, Linq To Object, Linq To SQL, Linq To XML
Categories : Architecture, Linq, Linq To Object, Linq To SQL, Linq To XML