Open AMT1990 opened 5 years ago
This has become a common enough question that I've created an FAQ page to help answer.
https://github.com/MarimerLLC/csla/blob/master/docs/serialization.md
Your class is using private backing fields with MobileFormatter
. You need to either use managed backing fields (recommended) or override OnGetState
/OnSetState
to get/set each field value in the serialization stream.
[Serializable]
public class OrderStatus : CommandBase<OrderStatus>
{
public static readonly PropertyInfo<string> OrderIdProperty = RegisterProperty<string>(c => c.OrderId);
public string OrderId
{
get { return ReadProperty(OrderIdProperty); }
private set { LoadProperty(OrderIdProperty, value); }
}
public static readonly PropertyInfo<string> NewStatusProperty = RegisterProperty<string>(c => c.NewStatus);
public string NewStatus
{
get { return ReadProperty(NewStatusProperty); }
private set { LoadProperty(NewStatusProperty, value); }
}
public OrderStatus()
{ }
private OrderStatus(string orderID, string newStatus)
{
OrderId = orderID;
NewStatus = newStatus;
}
public static void SetStatus(string orderId, string newStatus)
{
var orderStatus = new OrderStatus(orderId, newStatus);
DataPortal.Execute<OrderStatus>(orderStatus);
}
protected override void DataPortal_Execute()
{
string orderId;
string newStatus;
if (OrderId != null)
orderId = OrderId;
if (NewStatus != null)
newStatus = NewStatus;
}
}
Question I tried to execute below program in .net core with CSLA 4.9.0
To run the code sent values to OrderStatus.SetStatus("1", "new"); method. From SetStatus method provide and assign that values to global variables like _orderID and _newStatus i.e _orderID=1 and _newStatus="new".
Then run the below line of code DataPortal.Execute(orderStatus);
After execute it will goes to DataPortal_Execute() method But I am getting this._orderID and this._newStatus as null, but we already assign value earlier to global variables as _orderID=1 and _newStatus="new" That problem only in .net core but in .net framework its working fine. Please help with any solution for it.
Version and Platform CSLA version: 4.9.0 OS: Windows. Platform: .NET Core.