How do you use the LINQ to SQL designer to generate accessor methods for subclasses?
Posted
by Pricey
on Stack Overflow
See other posts from Stack Overflow
or by Pricey
Published on 2010-03-29T23:36:40Z
Indexed on
2010/03/29
23:43 UTC
Read the original article
Hit count: 429
Above is the LINQ to SQL designer view for my data context.
Below is the relevant code:
public System.Data.Linq.Table<ActivityBase> ActivityBases
{
get
{
return this.GetTable<ActivityBase>();
}
}
...
[Table(Name="dbo.Activities")]
[InheritanceMapping(Code="1", Type=typeof(ActivityBase), IsDefault=true)]
[InheritanceMapping(Code="2", Type=typeof(Project))]
[InheritanceMapping(Code="3", Type=typeof(ProjectActivity))]
[InheritanceMapping(Code="5", Type=typeof(Task))]
[InheritanceMapping(Code="4", Type=typeof(Activity))]
public abstract partial class ActivityBase : INotifyPropertyChanging, INotifyPropertyChanged
{
...
Is there a way to generate accessor methods for the subclasses as shown in the inheritance mapping above (Project, Task, etc...) without doing it manually? I added them manually but then a change in the designer overwrites any manual changes.
Am i doing this wrong? should I not be making accessors for the sub classes? filtering from ActivityBase seems worse to me.
Thanks for any help on this.
© Stack Overflow or respective owner