I'm designing my database and LINQ To SQL ASP.NET web application.
Imagine I have two types of pages: normal and root. Some pages are roots. Some pages are not.
I have a Page database table and a RootPage database table:
Page
----
PK PageId
HtmlTitle
PageHeading
MetaDescription
IsRoot
RootPage
--------
FK PK PageId
FavIcon
StyleSheet
MasterPage
I think that if within my DBML file I set the IsDiscriminator property of the IsRoot column, then my RootPage class will inherit the Page class.
I want to be able to work like this in my code:
MyDataContext db = new MyDataContext();
var roots = from p in db.Pages
where p is RootPage
select (RootPage)p;
Or like this:
RootPage r = new RootPage();
r.HtmlTitle = "Foo";
r.FavIcon = "bar.ico";
...
db.Pages.Add(r);
db.SubmitChanges();
Can a LINQ to SQL IsDiscriminator column be nullable or false? Will this work?