error description:
linq entities not recognize method 'system.string tostring()' method, , method cannot translated store expression.
the error comes while executing following code:
public actionresult newbooking() { var db = new virtualticketsdbentities2(); ienumerable<selectlistitem> items = db.attractions .select(c => new selectlistitem { value = c.a_id.tostring(), text = c.name }); viewbag.categoryid = items; return view(); }
any suggestion rid of error?
thanks.
you can use asenumerable()
change binding context linq-to-entities linq-to-objects:
ienumerable<selectlistitem> items = db.attractions .asenumerable() .select(c => new selectlistitem { value = c.a_id.tostring(), text = c.name });
Comments
Post a Comment