Hello,
I'm using Visual Studio 2010 Express with Framework 4.0 and if I am correct, it comes with Entity Framework 4.
My ObjectContext is defined as:
public partial class CreaturesEntities : global::System.Data.Objects.ObjectContext
I tried to use ExecuteStoreQuery :
using System.Data.Objects;
using System.Data.Entity;
[...]
context = new CreaturesEntities();
string query = "select type, min(value) value from saving_throw where ";
string conditions = "(classe_id=" + classe_id + " and level=" + level1 + ")";
if (classe.subclass1_id != null)
conditions += " or (classe_id=" + classe.subclass1_id + " and level=" + level1 + ")";
if (classe.subclass2_id != null)
conditions += " or (classe_id=" + classe.subclass2_id + " and level=" + level2 + ")";
if (classe.subclass3_id != null)
conditions += " or (classe_id=" + classe.subclass3_id + " and level=" + level3 + ")";
query = query + conditions + " group by type";
var q = context.ExecuteStoreQuery<SimpleNumber>(query);
// SimpleNumber is a class with an int property, I suppose ExecuteStoreQuery<Integer> wouldn't work?
When I type "context.", I can't find ExecuteStoreQuery in context menu, which means it is not available for whatever reasons. I can't find anything about a missing method in ObjectContext. Does this mean that Visual Studio 2010 Express doesn't include Entity Framework 4 ? Because standard edition does, and it would be strange that express edition uses an older version.
Of course, I could use a classic DataReader but ExecuteStoreQuery is a lot better.
Any idea?
Edit : I change query to the real one to explain why ExecuteStoreQuery is sometimes easier for complex query (at least for beginners in LINQ To Entities)