I used to have a straight up controller returning a view like this
return View(db.Stuff.ToList());
This works fine. I started laborating a bit and found that this:
var items = from g in db.Stuff
select g;
return View(items);
...also works fine. However, as I try to join with another table :
var items = from g in db.Stuff
join ug in db.OtherStuff on g.Id equals ug.StuffId
where !ug.UserId.Equals(1)
select g;
return View(items);
I get an error in the view saying:
Unable to create a constant value of type 'System.Object'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
Why is this? Another odd thing is that if I comment out the where clause, it seams to work again (work as in not throw an exception)
尝试将where子句更改为此:
where ug.UserId != 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.