How to fix problems with Linq and the Entity Framework « « Digital Tool Factory blog

How to fix problems with Linq and the Entity Framework

database 2

The Problem:

You attempt to do a query using Linq To Entities and your code does not work.

The Cause:

For reasons unknown, Linq to Entities has different operators than Linq To Sql.

The Solution:

Call your initial query/pull and us .ToList() on it before you run any of the problem operators – this fixes the problem entirely.
I am embarrassed to say that I spent 30 minutes trying to get Linq to Entities to work directly before I thought of that.

Creative Commons License photo credit: Tim Morgan

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog

About the author

Steve French Steve is the President and lead developer of Digital Tool Factory and currently provides all technical development for DTF. Digital Tool Factory has provided behind the scenes technical muscle to the Atlanta design community since 2002.Google+ Profile

 

Written By Steve French

 

Leave a Reply





Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.