/Home /Archive /Syndicate /Blog /Support /About /Contact  
All Visual Basic Feeds in one place!





I've been asked this question enough times that I thought I would blog it. While it may seem obvious to some, it is not to everyone who is just starting out with Entity Framework or LINQ to SQL or ADO.NET Data Services.

When you write a query against an Entity Data Model or a LINQ to SQL model that query is what goes to the server.

There are people who are concerned that the filters don't get applied until after the data has been returned from the server.

In other words if you write a LINQ to Entities query such as

  DateTime olddate = DateTime.Now.AddYears(-1);
  IEnumerable
employee = from e in context.Employees where e.StartDate
> olddate select e;
 

The store query that is executed on the server includes the Where StartDate>'4/1/2008' filter.

LINQ to SQL works the same way. ADO.NET Data Services works the same way.

If you are wondering why I separated the date calculation to another line of code, that is becasue LINQ to Entities can use the date parameter, but it cannot interpret the AddYears function. Therefore, I let .NET calculate the date for me in advance.

© 2005 Serge Baranovsky. All rights reserved.
All feed content is property of original publisher. Designated trademarks and brands are the property of their respective owners.

This site is maintained by SubMain(), a division of vbCity.com, LLC