c# 4.0 - Iteration over a linq to sql query is very slow -


I have a view, AdvertView in my database, this view includes some tables (ads, customers, attributes). After that I have a simple Linux query to bring all the advertisements for a customer:

  Public InenMerebal & lt; AdvertView & gt; GetAdvertForCustomerID (int customerID) {var advertlist = advert to _dbcontext.AdvertViews where advert.Customer_ID.Equals (customerID) select ad; Return advertisement list; }  

Then I want to map it to the model of my model:

  public list & lt; AdvertModelItem & gt; GetAdvertsByCustomer (Intel Customer ID) {List & lt; AdvertModelItem & gt; LstAdverts = new list & lt; AdvertModelItem & gt; (); & Lt; AdvertView & gt; AdViews = _dataHandler.GetAdvertForCustomerID (customerId) .Olist (); Foreign exchange (see ad view in ad view) {lstAdverts.Add (_advertMapper.MapToModelClass (adView)); } Return lstAdverts; }  

I expected that there are some performance problems with SQL, but the problem is with the .toList () function. I am using ANNS Display Profiler and it reports that the total runtime of the function is 1.400 ms, and 850 of them are with TOList (), so my question is, why do the listing work take so long ?

GetAdvertForCustomerID does not return results, it returns a query.

ToList enumerates inquiries. The results are hydrated at that point of the database, getting within the ToList call.

You should retrieve the generated SQL (using SqlProfiler or DataContext.Log property), and it should be taken to the query analyzer (set stats Io On) to perform the execution plan and IO.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -