c# - Entity Framework 4.0 won't let me use LINQ-to-Entities -
maybe i'm over-worked ... i'm lost in project use ef4 db stuff.
as such, work indeed retrieve complete list of entity. when try filtering, don't it...
i have following code, in big trouble
public class infoviewmodel { private trackerentities _context; public infoviewmodel (int ticketid) { var ct = new trackerentities(); var res = t in ct.tickets t.ticketid // vs2010 can't evaluate property 'ticketid' select t; } }
i not understand why t.ticketid throws me wavy red line error message "can not resolve symbol 'ticketid'"
the symbol declared in edmx file, public getter , setter...
in fact, looks nothing of entity known in class.
why?
tia deepcore
1) should compare ticketid of entity desired match, , (recommended) should wrap context instance in using
statement (it's idisposable
):
private trackerentities _context;
public infoviewmodel(int ticketid)
{
var ct = new trackerentities();
var res = t in ct.tickets
wheret.ticketid == ticketid
select t;
}
2) try refreshing model; go edm designer, right click surface , select "update model database", maybe there error in schema.
3) make sure ticketid
property same spelling , casing in edm.
4) make sure ticketid
int
and compare int in updated snippet above.
Comments
Post a Comment