Reputation: 51
I want to Validate (IDataErrorInfo) of my properties which are generated through the Telerik OpenAccess Mapper.
Like this.
public partial class Etage
{
private long _version;
public virtual long Version
{
get
{
return this._version;
}
set
{
this._version = value;
}
}...
Now i want to override the property "Version" in my second class Etage (also partial) like this.
public partial class Etage : IComparable
{
public override long Version
{
get { return _version; }
set { _version = value+200; }
}
// Some Validation in the Setter later...
public override string ToString()
{
return String.Format("{0}", Version);
}
}
Then i get the following Error:
Ambiguity between 'Inventar.Model.Etage.Version' and 'Inventar.Model.Etage.Version'
Upvotes: 0
Views: 896
Reputation: 2318
You can control how the OpenAccess code generator creates its code by modifying the TT templates that it uses. Here are some links that should get you on the right track:
INotifyPropertyChanging/ed
Interface (C#)
IDataErrorInfo
.INotifyPropertyChanging/ed
Interface (VB.NET)Upvotes: 0
Reputation: 1108
There isn't a way to override properties in a partial class, you need to do it in a derived one. However using a derived class might not help, given that the OpenAccess context will retrieve instances from the base class and there isn't an easy way of converting those to your new types.
What you can do is add a property with a different name (in the partial class), that does the neccessary calculations. This however will mean that you will have both exposed on the model. In order to fix that you can change the access modifier of the generated property trough the visual designer. Just find the property and change it's access modifier in the properties pane to something different from public.
Upvotes: 1
Reputation: 14002
This might work:
public partial class SubEtage : Etage
{
public override string Beschreibung
{
get { return base.Beschreibung; }
set { base.Beschreibung = value + "GEHT"; }
}
public override string ToString()
{
return String.Format("{0}", Beschreibung);
}
}
And check out the links:
http://www.telerik.com/help/openaccess-orm/openaccess-tasks-howto-single-class-single-table.html
Upvotes: 0