c# - Cannot cast anonymous return type from query to an entity type -


I'm struggling with a problem (usually simple to deal with).

I have a database that contains the "Measurement" table. Each measurement has a timestamp (Ditareum), a value (decimal), measurement type (foreign key in the lookup table) and that "capability item" Table).

I created an SQL database in the Imported Framework Framework and a model outside it. Now I want to query for the base line is the current state of a base line capacity item, and the items with that special capacity are presented by the latest measurements of each type.

Therefore the query needs to be returned: For a certain capability item, give me the latest measurements of each measurement type. In the SQL query, I have to maximize on a "group" and timestamp on the type of measurement. But in linq-2-entities I think swinning in the soil. I need a function that is IQueryable & lt; Measurement & gt; , which includes all basic measurements, but my queries return all kinds of unknown types that are impossible for typedcaster.

I hope that I have made myself clear. When I read it again, I can imagine that it does not matter much. But I am looking for it for a very long time, and my mind is starting to do funny things: -)

Anyone who can get me in the right direction?

~ Rob

= "Text">

Something like this:

  var q = From the meter in context Group by group M.MeasurementType.M in Bl group in group where bl.TimeStamp == group. Select Maximum (G = & gt; TimeTemplate) BL;  

It is far from the top of my head and is guessing about your DB. You may have to do more to it.


Comments