Linq to SQL not querying memory -


I was questioning results of a query that I memory'm using Linq to SQL and always thought . I have just seen the database and it is showing thousands of questions instead of 1, which I expected.

My approach has been to run a query and then use the linq to find within the resultset. / P>

  IQueryable & lt; Mapping & gt; FieldList = db.mappings is equal to db.meta Join mm.secondaryMetaItemId miles mm Select mi.metaItemId db.meta meet objects mo.metaObjectId where mm.linkageId == 277 mm mi.metaObjectIbjects on; (Int i = 0; i & lt; 100; i ++) {for mapping thisVar = fieldList.FirstOrDefault (M = & gt; m.primaryItem == info.Name) for; }  

How can I stop Linq to use my resultset every time ...

Thank you for your help!

FirstOver Default () is an example of a method that calculates on the result (the first result should be found). You want to call a method or otherwise calculate the results once. This way, when you want to refer to those results throughout your program, you can do it in a cached copy.

The easiest way is that you can convert it to the list. This will put the results in memory as a list. You can then use it.

  IQueryable & lt; Mapping & gt; FieldList = db.mappings is equal to db.meta Join mm.secondaryMetaItemId miles mm Select mi.metaItemId db.meta meet objects mo.metaObjectId where mm.linkageId == 277 mm mi.metaObjectIbjects on; // Help! Var result = field list. ToList (); // query results only once is processed // content (Inti I = 0; i & lt; 100; i ++) accumulated using {// result thisVar = result.FirstOrDefault (m = & Gt; m.primaryItem == info .name); }  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -