This question is locked. New answers and comments are not allowed.
Dear Telerik,
I am trying to use automatic versioning via telerik fluent mapping but I can't seem to get it to work.
My basic example:
which has the following mapping:
and the following unittest:
Gives the following result in the database:
i_d: 1
nme: Barkinson (so, it did save it twice)
vrsion: 0 <-- I expected 2 here!
What I wish to achieve is make the version field auto increment every time the entity is saved (which in this case is two times). I assumed the method IsVersion() could be used for this. Is this possible or should I implement this functionality in the domain layer?
Kind regards,
Roderik Steenbergen
I am trying to use automatic versioning via telerik fluent mapping but I can't seem to get it to work.
My basic example:
public class Dog
{
public int ID { get; set; }
public string Name { get; set; }
public long Version { get; set; }
}
which has the following mapping:
MappingConfiguration<
Dog
> dogConfiguration = new MappingConfiguration<
Dog
>();
dogConfiguration.MapType().ToTable("dogs");
dogConfiguration.HasProperty(p => p.ID).IsIdentity(KeyGenerator.Autoinc);
dogConfiguration.HasProperty(p => p.Version).IsVersion().IsNotNullable();
preparedConfigurations.Add(dogConfiguration);
and the following unittest:
Punt4FluentContext dbContext =
new
Punt4FluentContext(
dbConnection, sqlConfiguration);
Dog dog =
new
Dog();
dog.Name =
"Droopy"
;
dbContext.Add(dog);
dbContext.SaveChanges();
Punt4FluentContext dbContext2 =
new
Punt4FluentContext(
dbConnection, sqlConfiguration);
dbContext2.GetAll<Dog>().First().Name =
"Barkinson"
;
dbContext2.SaveChanges();
Gives the following result in the database:
i_d: 1
nme: Barkinson (so, it did save it twice)
vrsion: 0 <-- I expected 2 here!
What I wish to achieve is make the version field auto increment every time the entity is saved (which in this case is two times). I assumed the method IsVersion() could be used for this. Is this possible or should I implement this functionality in the domain layer?
Kind regards,
Roderik Steenbergen