I have this LINQ query that ends in a custom type such as:
< Select code> new {this1 = table.this1, this2 = othertable.this2}
The caller calls that query to look something like this:
ViewData ["These"] = Repos. Meet all (some wind, another);
Now when I pass it on my point of view because it is not typed strongly, how can I repeat it with the future through it, how can I call it an IQueryable or Can I put in a list if I know what's in it?
... something like that?
IQueryable & lt; ??? & Gt; These = viewdata ["these"]; Foreach (In these var) {...
Just '???' I need to put what I need to do.
Your linq query returns an archive of type objects anonymously. Being unknown, there is no way to "call on their name" while declaring a clearly typed variable. Thus, the right type / size of objects is known only within the action method where the objects are defined.
ViewData is a return type of the indexed recipient of the object,
object
, and without the type name, you want it to return See the value of data ["these"]
is anything useful.
What you might want to do instead, make a model - more specifically - that defines the structure that you are using LINQ:
public class FoobarViewModel {public string Foo {get; Set; } Public string bar {get; Set; }}
and re-define your query to make such a selection:
New FoobarViewModel {foo = table.this1, bar = othertable Select this2}
Your object now shares a normal named class, and your collection can be easily tracked in the view.
No comments:
Post a Comment