Change LINQ2SQL property in partial class?
Posted
by Fermin
on Stack Overflow
See other posts from Stack Overflow
or by Fermin
Published on 2010-04-19T12:37:29Z
Indexed on
2010/04/23
10:03 UTC
Read the original article
Hit count: 335
linq-to-sql
|c#
Hi,
I have a table in my LINQ2SQL diagram with a column called DayOfWeek in table JourneyBooking. The designer.cs has the definition of this as:
[Column(Storage="_DayOfWeek", DbType="TinyInt NOT NULL")]
public int DayOfWeek
{
get
{
return this._DayOfWeek;
}
set
{
if ((this._DayOfWeek != value))
{
this.OnDayOfWeekChanging(value);
this.SendPropertyChanging();
this._DayOfWeek = value;
this.SendPropertyChanged("DayOfWeek");
this.OnDayOfWeekChanged();
}
}
}
I have a partial class for the JourneyBooking class. Is it possible to extend/overwrite the above DayOfWeek property with my own property?
The issue I am having is that DayOfWeek is 0-6 in C# but 1-7 in SQL, so I was thinking that I could overwrite the DayOfWeek property to subtract or add 1 depending on whether it was a get or set, is this possible or would I need to re-write all of the above code in my partial class?
© Stack Overflow or respective owner