Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple way to return anonymous types (to make MVC using LINQ possible)
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. COWhen you are working with a orm you should get used to the thought of having the sql select all columns of a table. If you write queries that selects only a few you might just as well be using sql in the first place. If you have dozens of properties on your objects then that is your problem. Your objects should be smaller and you should think about how you can fix that. Anonymous types should not be passed around, specially not as models to a view.
      singulars
    2. CO@Mattias: Unfortunately, life is not so simple. For example, consider the case where I select a few columns from different tables, including an array of objects selected using an inner-LINQ query. As far as I'm aware, there's no way to return that as a single EF object - it *has* to be a new type, and defining a new concrete type for every query like this is ridiculously cumbersome.
      singulars
    3. COSounds to me like you have a pretty bad model. Your object should have the references that it needs and you can just use the "Include()" method in EF (to eagerly load that data). If you stop thinking about the data as different columns in different tables, and more about your model (more OO) it will most likely be a lot easier to work with. Bottom line: If you feel the need to pass around anonymous types you are most likely doing something else wrong.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload