Florent Clairambault

LinQ : Join with multiple conditions

I wanted to some simple join in LinQ on multiple criteria. And coming from standard SQL it’s not as straightforward as I thought it would be. The little disturbing thing is that you lose auto-completion. Here is my database schema : User: * UserId int (PK) * Login String * DateOfBirth DateTime Parameter: * ParameterId int (PK) * Name String User_Parameter: * UserId int (FK User:Userid) * ParameterId int (FK Parameter:ParameterId) * Value String If you want to fetch the “PreferredSuperHero” parameter, you have to execute :

LinQ to Entities on ADO.Net vs LinQ to SQL

Overview To make it short : LinQ to SQL only works with SQL Server but it’s working great. It’s simple, supports all LinQ operations and optimizes the generated SQL queries. LinQ to Entities on ADO.Net works with lots of database but it doesn’t behave like LinQ to SQL and doesn’t support some key LinQ features. Now the long story : For the last project I’ve been working on, we wanted to use LinQ and still be able to switch to one database to an other (MSSQL to MySQL for instance).