Pergunta

I have added persistance classes in my web application using XPO from DevExpress.

Now I want to get data dynamically using XPQuery. Dynamically means: I have got all the class names for particular assembly:

 Type[] typelist = typeof(Sample.Students).Assembly.GetTypes();

Now using typelist[2], I want to get data from table containing typelist[2].

How can I do it? Tables are listed in typelist and based on that I have to create XPQuery<> object and then want to get data using LINQ Query: How can I do it? Thanks

Foi útil?

Solução

Try this:

// change typelist index as needed 
Type xpQueryGenericType = typeof (XPQuery<>).MakeGenericType(typelist[0]);
var xpQueryInstance = Activator.CreateInstance(xpQueryGenericType, new object[]{xpoSession});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top