I have a stored procedure that returns a dynamic query, e,g if i pass some value to its id
parameter it return me a dynamic query like
Select * from someTable tbl where tbl.Id=51
then i execute this query using ExecuteStoreQuery
like
string query = container.CreateQuery<string>(
"SELECT VALUE DB.Store.GetQuery(@ID) FROM {1}",
new System.Data.Objects.ObjectParameter("ID", 51)
).First();
object lists = container.ExecuteStoreQuery<object>(query);
the problem is container.ExecuteStoreQuery<object>(query);
returns multiple rows which i want to get into a list, how can i do that
create a model of type you want to return the results like
public class mymodel{
public int _key{get;set;}
public string _value{get;set;}
}
where _key
and _value
correspond to the columns of the returned result
execute the query ExecuteStoreQuery
also return the result AsQueryable
container.ExecuteStoreQuery<mymodel>(query).AsQueryable().ToList();
I'm not sure if I understand your question but it looks like you are looking for ToList
method:
List<MyEntity> list = container.ExecuteStoreQuery<MyEntity>(query).ToList();
The bigger problems is object
in your code - if you really mean object
type it will not work. You must provide a real type (either mapped entity, complex type or custom class with public properties using same names as columns in result set) otherwise EF will not fill data for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With