c# - Passing more multiple queries in a View ASP.NET -
in repository class have 2 queries want appear in 1 view:
public classxxxx getxxxolist(string name) { return context.classxxxx.where(v => v.name == name).single(); }
and second query in repository class have:
public ienumerable<classxxxx> list() { return context.classxxxx.tolist(); }
then in view doing this:
@model ienumerable<namespace.models.classxxxx> @model namespace.models.classxxxx
to return 2 queries in view respectively. asp.net throws exception on using @model twice in 1 view.
instead of:
@model ienumerable<namespace.models.classxxxx> @model namespace.models.classxxxx
you can create viewmodel class, contains needed data:
public class yourcontextviewmodel { public list<person> person { get; set; } public string username{get;set;} ... }
it's idea create viewmodel object populate views.
Comments
Post a Comment