I have two app. The one use XAF (devexpress framework), the second use asp.net mvc.
My bussines classes is created in XAF app. Both use same database.
My classes in XAF:
public class BaseClass:XPObject
{
// some fields
}
// This attribute mean that all fields will be stored in BaseClass table
[MapInheritance(InheritanceType.ParentTable]
public class Class1:BaseClass
{
// some fields
}
// This attribute mean that all fields will be stored in BaseClass table
[MapInheritance(InheritanceType.ParentTable]
public class Class2:BaseClass
{
// some fields
}
In a DB we have one table: BaseClass with fields from BaseClass, Class1.
There are such moment: XAF adding own field called ObjectType (it’s FK to XPObjectType table which XAF create automatically).
In result we have in a DB:
BaseClass:
ID some_fields_from_BaseClass some_fields_from_Class1 ObjectType
1 some_values some_values 1
XPObjectType:
ID TypeName AssemblyName
1 TestApp.Module.BO.Class1 TestApp.Module
Now, I wrote in the ASP.NET MVC app:
Database.BaseClasses.Where( ...some predicate...).ToList();
This query return me collection of BaseClass. But, I want that query return me derived types (Class1 or Class2 or Class 3, for example).
How can I do this?
PS. I can’t use IsDiscriminator attribute because it’s FK and I don’t want to diplicate objects (Class1, class2 in asp.net mvc app).
Try this one: