views:

65

answers:

2

What is an abstract type in context of Entity Framework inheritance?

A: 

Abstract types are types/classes which cannot be instantiated. Meaning you cannot create objects from this class. If you have an abstract class 'foo', you cannot call new foo()(Java example code). See wiki for more information on abstract types.

Anzeo
This *is* a correct answer about abtract types, although not (as requested) in the context of Entity Framework.
Hans Kesting
I couldn’t find any reference on the web to any concept called *abstract class* that is specific to Entity Framework and different from the “normal” meaning, so this answer seems appropriate.
Timwi
I probably should have specified the concept of an abstract type as being a general concept and not bound to the context of Entity Framework. My bad!
Anzeo
A: 

the whole point of an abstract class is tha tyou inherit from it and cant create in instance directly.

so in entity framework its represents the normalisation of data out of several tables into one common table and then using by table inheritance to have a set of objects with varying types that can be tret as one type.

assuming you have an abstract class called object and some inheritors of it that have data in the tables ...

you can then write things like this

var results = from i in dataContext.Objects.OfType<Foo>()
              select i

you can also do this

var results = from i in dataContext.Objects
                  select i

and you will get a collection of abstract class Object, each member of which will be an instance of a class that inherits from object.

It means that you can have common behaviour or overridden behaviour in sub types. Its very powerful in the right places ... .eg transaction types or payment method types.

John Nicholas