.net - Is this a recommended way to use a Stored Procedure with Entity Framework 4? -
my code doing 2 round trips database because i'm not sure if correct way create collection of poco's first round trip hits stored procedure because of specific sql code.
scenario
a user enters autocomplete search query ui. code hits stored procedure (which taking advantage of f*ull text search* - hence reason i'm using stored procedure) , returns distinct primary keys of results. these go code (my irepository class) , use ef retrieve results, these stored procedure result.
firstly, don't know how in linq entities : collection of id's, retrieve foo entities.
secondly, i'm doing 2 round-trips database. why? because i'm not sure how can retrieve rich results in first round trip. entity consists of few poco classes , has 2 icollection properties also, etc...
is correct way should using stored procedure , retrieving rich, populated entities.
i'll create dummy class diagram answers.
public class person { string name; int age; icollection<string> nicknames; icollection<foo> donnosomethingelses; } thoughts?
well, 2 roundtrips sound avoidable problem - couldn't like:
with fulltextresults ( select id, ...... --- full text search here ) select (list of fields) dbo.yourdatatable t inner join fulltextresults ftr on t.id = ftr.id -- join on primary key ..... -- possibly limit results and return output of cte (common table expression) stored proc?? return data set rows , columns actual data table, , ef materialize person classes that.....
Comments
Post a Comment