Pregunta

Here is my working Code:

var queryString = "SELECT VALUE c " +
                  "FROM EMI_ERPContext.Customer AS c " +
                  "WHERE c.FirstName='Emanuel'";
ObjectQuery<Customer> customers = ((IObjectContextAdapter)context).ObjectContext.CreateQuery<Customer>(queryString);

This code works fine. But I would like to be able, make this available for any Type. At the moment it works only for Customer. Making the queryString dynamic is easy, but how I would call this Line:?

ObjectQuery<ANYTYPE> anytypeObjects = ((IObjectContextAdapter)context).ObjectContext.CreateQuery<ANYTYPE>(queryString);

Is there a way to call the CreateQuery, without needing to give a specific Type or is there easy way I can make this work? Thanks for any advice!

¿Fue útil?

Solución

I did it.. , using

ObjectQuery<dynamic> anytypeObjects = ((IObjectContextAdapter)context).ObjectContext.CreateQuery<dynamic>(queryString);

works fine!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top