EF4 - пользовательский ObjectContext и вопрос о наследовании

Если вы используете ng-pattern = '/ some_reg_ex /'. Пожалуйста, сохраните его в некоторой переменной области видимости, скажем, $scope.emailPattern = '/email_regex/'

10
задан Community 23 May 2017 в 12:08
поделиться

1 ответ

If you create an ObjectSet for a base type (i.e. Post) you can't create one for derived types too, because you can retrieve instances of all types in the inheritance hierarchy from that one ObjectSet.

i.e. ctx.Posts.OfType() would return BlogEntry(s).

So the answer is to simply remove the other two sets.

If yo need to do an add for example you can do this:

ctx.Posts.AddObject(new BlogEntry {....});

no problem at all.

To help you write queries more easily you could probably add a couple of properties to your ObjectContext that look like this:

public ObjectQuery<BlogEntity> Blogs{
   get{
       return ctx.Posts.OfType<BlogEntry>() as ObjectQuery<BlogEntry>;
   }
} 

and the same for comments.

Hope this helps

Alex

11
ответ дан 4 December 2019 в 01:03
поделиться
Другие вопросы по тегам:

Похожие вопросы: