开发者

What is an abstract type?

What is an abstract type in context of Entity Fr开发者_如何学Goamework inheritance?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜