Csla 5 to 8 upgrade, dealing with non-csla properties. #4456
-
Hello, We are updating an application from csla 5 to 8. One thing that changed is how non-csla variables become null in dataportal updates (probably other places too). For example: public class Example : BusinessBase<Example>
{
private string _nonCsla;
public static readonly PropertyInfo<int> IdProp = RegisterProperty<int>(c => c.ID);
public int ID => GetProperty(IdProp);
[Fetch]
void Fetch()
{
_nonCsla = "SOME VALUE";
}
[Update]
void Dataportal_Update()
{
//in csla 5, _nonCsla would be "SOME VALUE"
//in csla 8, its null
}
} These type of noncsla properties are all over the app, and while it is possible to refactor them to become CSLA properties, I first want to ask is there some attribute they can be marked with, or some setting that would restore that behavior of them showing up in Update/Insert/Delete dataportals. I tried searching through the discussions and couldn't find anything, and I tried marking the properties with various attributes in the Csla serialization namespace without working. Some properties are primitives, there are few POCOs as well. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Microsoft has stopped supporting the BinaryFormatter, and so CSLA has also stopped using it. As a result, the serializer is now MobileFormatter. MobileFormatter automatically works with managed backing fields. If you have private backing fields or non-CSLA properties, then it is up to you to set/get the values during serialization. To do this, there are methods you can override to participate in the serialization process. public string SomeValue { get; set; } = "SomeValue";
protected override void OnSetState(SerializationInfo info, StateMode mode)
{
info.AddValue(nameof(SomeValue), SomeValue);
base.OnSetState(info, mode);
}
protected override void OnGetState(SerializationInfo info, StateMode mode)
{
SomeValue = info.GetValue<string>(nameof(SomeValue));
base.OnGetState(info, mode);
} |
Beta Was this translation helpful? Give feedback.
Microsoft has stopped supporting the BinaryFormatter, and so CSLA has also stopped using it. As a result, the serializer is now MobileFormatter.
MobileFormatter automatically works with managed backing fields. If you have private backing fields or non-CSLA properties, then it is up to you to set/get the values during serialization.
To do this, there are methods you can override to participate in the serialization process.