Welcome to MSDN Blogs Sign in | Join | Help

March 2009 - Posts

Tip 9 – How to delete an object without retrieving it
Problem The most common way to delete an Entity in the Entity Framework is to pull the Entity you want to delete into the context and then delete it like this: // Find a category by ID by // TRIVIA: in .NET 4.0 you can use .Single() // which will throw Read More...
Tip 8 - How to write 'WHERE IN' style queries using LINQ to Entities
Imagine if you have a table of People and you want to retrieve only those whose the Firstname is in a list of interesting firstnames. This is trivial in SQL, you write something like this: SELECT * FROM People WHERE Firstname IN ('Alex', 'Colin', 'Danny', Read More...
Tips and Tricks
Hopefully if you're reading this you've noticed that I've started a series of Tips recently. The tips will mostly apply to Entity Framework or Data Services. Seeing as I expect to have a lots of tips, it probably makes sense to have some sort of index. Read More...
Tip 7 - How to fake Foreign Key Properties in .NET 3.5 SP1
Background If you've been reading the EF Design Blog you will have seen that we recently announced something called " FK Associations " for the EF in .NET 4.0. However in .NET 3.5 SP1, we only support Independent Associations. What that means is that Read More...
Self-Tracking Entities
Some of the feedback we got on the EF design blog about our early N-Tier plans , highlighted that lots of people just want the whole "tier thing" to just work out of the box. Fortunately now that we have adopted T4 to generate our entities we have lots Read More...
Tip 6 - How and when to use eager loading
When should you use eager loading? Usually in your application you know what you are going to "do" with an entity once you have retrieved it. For example if you retrieve an order so you can re-print it for a customer, you know that the re-print would Read More...
Tip 5 - How to restrict the types returned from an EF Query.
Imagine you have a model that looks like this: How do you query for just Cars? This is where OfType<SubType>() comes in. You write something like this: var onlyCars = from car in ctx.Vehicles.OfType< Car >() select car; And this works, fine. Read More...
Tip 4 - Conceptual Schema Definition Language Rules
The first version of the Entity Framework was released a while back ago now with .NET 3.5 SP1. One of the most glaring holes in the Entity Framework documentation was the lack of a formal document describing the Conceptual Schema Definition Language or Read More...
Tip 3 - How to get started with T4
So if you've been reading the Entity Framework Design Blog you will have heard us talk about T4 . It is a technology that ships with Visual Studio 2008 (and 2005 as a separate download). In .NET 4.0 the Entity Framework is leverage T4 to help with Code Read More...
Alt.NET Seattle
I went to Alt.NET Seattle on the weekend. Being from the Entity Framework team, I was a little nervous about how I'd be received. Well I definitely shouldn't have worried... everyone was very civil. In the broader sense I wasn't sure what to expect either, Read More...
Page view tracker