Thursday, October 27, 2011

in queries from sql to linq

try this:

List Ids = new List;
Ids.Add(1);
Ids.Add(2);
Ids.Add(3);

var t = from n in productList
where Ids.Contains(n.Id)
select n;

this is like:

select * from productList where Id in (1, 2, 3)

Tuesday, October 4, 2011

sql error in changing a db structure and saving again

Sometimes, we encounter sql error in changing a db structure and saving again.

The solution is:

Go to Tools -> Options of your SQL Management Studio.

Then, in the Designers -> Tables and Database Designers, uncheck the:

"Prevent saving changes that require table re-creation"

That it! Simple way, but mind boggling.

Thanks for reading!