I would like to save in the database a custom type property which is a class.
The property to save is myProperty
with the type CustomTypeClass
in the below example:
public class Test
{
private CustomTypeClass myProperty;
public CustomTypeClass MyProperty
{
get { return myProperty; }
set { myProperty = value; }
}
}
So, the value to save in the database is the result of the ToString
override method:
public class CustomType
{
public int Start { get; set; }
public int End { get; set; }
public CustomType(int start, int end)
{
this.Start = start;
this.End = end;
}
public override string ToString()
{
return "[" + this.Start + "," + this.End + "]";
}
}
I would like to perform the following code for saving in the database:
CustomType value = new CustomType(3, 5);
Test test = new Test();
test.myProperty = value;
database.Add(test);
database.SaveChanges();
How can I do this ?
At the moment, I get the following error:
Unsupported field-type 'CustomTypeClass' found for field 'myProperty' of class 'Test'.
Maybe you did not specify the TransientAttribute for this field or the PersistentAttribute is not specified for the referenced class. [class=Test]