c# - Using EF5 to bind to Data Grid View issue -
i'm new using ef , i'm using ef5 attempt bind data view data grid view in winforms app. i'm not sure how properly, , i'm getting error:
data binding directly store query (dbset, dbquery, dbsqlquery) not supported. instead populate dbset data, example calling load on dbset, , bind local data. wpf bind dbset.local. winforms bind dbset.local.tobindinglist().
here code:
using (myentities context = new myentities ()) { var qry = col in context.vwsystemproperties select new { systempropertyname = col.systempropertyname, systempropertyenumval = col.systempropertyenumval, systempropertyvalue = col.systempropertyvalue, applicationscope = col.applicationscope, categoryscope = col.categoryscope, entityscope = col.entityscope, versiondate = col.versiondate, versionuser = col.versionuser }; bindingsource bs = new bindingsource(); bs.datasource = qry; systempropertydgv.datasource = bs; }
i don't think understand error directing me do. i've done brief searching don't think i've found need. how dbset supposed implemented , used bind data dgvs, or there easier way?
can provide me insight on how bind qry object data grid view? right need view data, going forward able access row , update based on id.
thanks
just use tolist()
method on returned query.
try following:
using (myentities context = new myentities ()) { var qry = col in context.vwsystemproperties select new { systempropertyname = col.systempropertyname, systempropertyenumval = col.systempropertyenumval, systempropertyvalue = col.systempropertyvalue, applicationscope = col.applicationscope, categoryscope = col.categoryscope, entityscope = col.entityscope, versiondate = col.versiondate, versionuser = col.versionuser }; bindingsource bs = new bindingsource(); bs.datasource = qry.tolist(); systempropertydgv.datasource = bs; }
Comments
Post a Comment