c# - Can't get items from DDS via query LINQ -


i new c# asp.net , trying items store (episerver).

visual studio says

cannot resolve symbol where, onderzoekid , tolist

what doing wrong? used code example:

[episerverdatastore(automaticallycreatestore = true, automaticallyremapstore = true)] public class onderzoekcolumn {     private static int counter = 0;     public identity id { get; set; }     public int columnid { get; set; }     public int onderzoekid { get; set; }     public string columnname { get; set; }      public onderzoekcolumn()     {         initialize();     }      public onderzoekcolumn(int onderzoekid, string columnname)     {         initialize();          onderzoekid = onderzoekid;         columnname = columnname;     }      protected void initialize()     {         id = identity.newidentity(guid.newguid());         columnid = system.threading.interlocked.increment(ref counter);         onderzoekid = 0;         columnname = string.empty;     }      public static list<onderzoekcolumn> getonderzoekcolumns(int onderzoekid)     {         var store = typeof(onderzoekcolumn).getstore();          var columns = c in store                       c.onderzoekid == onderzoekid                       select c;          if (columns == null)         {             return new list<onderzoekcolumn>();         }          return columns.tolist<onderzoekcolumn>();     } } 

the linq statement

var columns = c in store               c.onderzoekid == onderzoekid               select c; 

is trying enumerate on collection, getstore() method returns single item. try using following code in place of getonderzoekcolumns method (its untested)

public static list<onderzoekcolumn> getonderzoekcolumns(int onderzoekid) {   var store = typeof(onderzoekcolumn).getstore();    var columns = store.items<onderzoekcolumn>().where(c => c.onderzoekid == onderzoekid);    return columns.tolist(); } 

i'd add following extension methods solution, can use typed find method, more efficient above, returns items, filters in memory using linq where() method.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -