c# - An expression tree may not contain a dynamic operator -
i'm trying join 2 tables. user , scoreboard
viewmodels>scoreboardvm.cs
public class scoreboardvm { public ienumerable<dynamic> scoreboards { get; set; } }
controller
var db = new gamedbdatacontext(); var userlist = (from s in db.scoreboards join u in db.users on s.user equals u.userid select new { username = u.username }).take(5); var viewmodel = new scoreboardvm(); viewmodel.scoreboards = userlist; return view(viewmodel);
view
@model project.viewmodels.scoreboardvm @foreach (var item in model.scoreboards) { @html.displayfor(model => item.username) }
the last line returns error "an expression tree may not contain dynamic operator" , i'm not sure means.
the error aree getting because public ienumerable<dynamic> scoreboards
dynamic , @foreach (var item in model.scoreboards)
dynamic not supported lambda expression
Comments
Post a Comment