Skip to main content
Home Forums Silverlight Programming WCF RIA Services RIA, Entity Framework and LINQ queries
2 replies. Latest Post by tkousek on November 6, 2009.
(0)
tkousek
Member
15 points
40 Posts
11-06-2009 8:14 PM |
Hi All
I'm getting more and more used to RIA/Entity Framework. It's pretty cool. I do have a question. I'm familiar with Linq synatically (and am trying to get familiar with it semantically) and how to use them with Linq to entities. I also consider myself quite proficient with SQL queries and complex joins/views as I have worked with SQL for quite a few years.
My question is this:
In my DomainService, I will have methods that do something similar to the following:
{
((row) => row.EvtSched_Id == id);
}
On the client, I get the correct data back which is my one row. However, help me to understand the following:
In the LinQ query above, will the actual query be executed in the database engine itself and ONLY the correct rows coming back to LinQ -(in this case just 1) or- will the database engine select ALL rows (and return 10000 rows) to LinQ and then will LinQ apply the filter on the 10000 rows retrieved. I'm hoping it's the former.
Some of the tables I have can get quite large. It would be a shame for (let's say) 10000 rows to come out of the event_schedule table above into a LinQ memory list and then have linq filter it out.
Also, I have indexes properly where I need to have them so I suspect LinQ to Entities will utilize the proper indexes within the queries.
Will Linq actually create the SQL statement based on the Linq query and the send that SQL statement with the where-clause (above) to the DB engine? I am looking for a good web-site and/or book that explains how LinQ (and LinQ to Entities) works behind the scenes so that I can assure my application performs efficient.
Normally in the past, I have always called stored procs or created prepared statements (with SQL) and sent them to the DB engine and used a DataReader along with SQLCommand objects and such. In this project, I'm trying to stay away from all of that and use just LinQ.
Please let me know if my question is confusing and if I need to reword it?
thanks again for all your help!!!
moravsky
Participant
896 points
164 Posts
11-06-2009 8:23 PM |
To give you a short answer, yes LINQ will do the efficient thing and only 1 row will be returned. If you want to see exactly what SQL gets executed, you should use SQL Profiler tool.
11-06-2009 9:08 PM |
Hello!!! You're awesome!!! Thanks for your help!!! I'll check into the SQL profiler tool!!!