This question is locked. New answers and comments are not allowed.
Hello,
I made a base class for all my entities.
public class EntityBase
{
private Guid id;
[DataMember]
public Guid Id
{
get { return id; }
set
{
if (Id != value)
{
id = value;
OnPropertyChanged();
}
}
}
private string name;
[DataMember]
public virtual string Name
{
get { return name; }
set
{
if (Name != value)
{
name = value;
OnPropertyChanged();
}
}
}
}
Implementation works like this:
public partial class Group : EntityBase
{
public Group()
{
Users = new List<User>();
}
public IList<User> Users { get; set; }
}
}
In the MetaSource class I implemented the mapping:
private void PrepareDefaultPropertyConfigurations<TEntity>(MappingConfiguration<TEntity> configuration)
where TEntity : IEntityBase
{
configuration.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Guid).IsNotNullable().HasColumnType("uniqueidentifier").HasPrecision(0).HasScale(0);
configuration.HasProperty(x => x.Name).IsNullable().HasColumnType("nvarchar").HasLength(100);
}
public void PrepareGroupPropertyConfigurations(MappingConfiguration<Group> configuration)
{
configuration.HasProperty(x => x.Note).HasFieldName("_note").WithDataAccessKind(DataAccessKind.ReadWrite).ToColumn("Note").IsNullable().HasColumnType("nvarchar(max)").HasLength(0);
PrepareDefaultPropertyConfigurations<Group>(configuration);
}
If I try to get the CreateUpdateDDlScript, I am getting the following error:
Mapping for field 'name' is specified in the file 'config', but the field is not present in the class 'Tortuga.Data.Entities.Group'. --> FromMetadataContainer/namespace[Tortuga.Data.Entities]/class[Group]/field[name]
How can I get the inheritance of mu base object working?
Thank you,
Manuell
I made a base class for all my entities.
public class EntityBase
{
private Guid id;
[DataMember]
public Guid Id
{
get { return id; }
set
{
if (Id != value)
{
id = value;
OnPropertyChanged();
}
}
}
private string name;
[DataMember]
public virtual string Name
{
get { return name; }
set
{
if (Name != value)
{
name = value;
OnPropertyChanged();
}
}
}
}
Implementation works like this:
public partial class Group : EntityBase
{
public Group()
{
Users = new List<User>();
}
public IList<User> Users { get; set; }
}
}
In the MetaSource class I implemented the mapping:
private void PrepareDefaultPropertyConfigurations<TEntity>(MappingConfiguration<TEntity> configuration)
where TEntity : IEntityBase
{
configuration.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Guid).IsNotNullable().HasColumnType("uniqueidentifier").HasPrecision(0).HasScale(0);
configuration.HasProperty(x => x.Name).IsNullable().HasColumnType("nvarchar").HasLength(100);
}
public void PrepareGroupPropertyConfigurations(MappingConfiguration<Group> configuration)
{
configuration.HasProperty(x => x.Note).HasFieldName("_note").WithDataAccessKind(DataAccessKind.ReadWrite).ToColumn("Note").IsNullable().HasColumnType("nvarchar(max)").HasLength(0);
PrepareDefaultPropertyConfigurations<Group>(configuration);
}
If I try to get the CreateUpdateDDlScript, I am getting the following error:
Mapping for field 'name' is specified in the file 'config', but the field is not present in the class 'Tortuga.Data.Entities.Group'. --> FromMetadataContainer/namespace[Tortuga.Data.Entities]/class[Group]/field[name]
How can I get the inheritance of mu base object working?
Thank you,
Manuell