MicroRuleEngine icon indicating copy to clipboard operation
MicroRuleEngine copied to clipboard

how to serialize data row rule

Open deep1234ea opened this issue 4 years ago • 2 comments

DataRule.Create("Column2", mreOperator.Equal, "123") & DataRule.Create("Column1", mreOperator.Equal, "Test");

I used this example and want to serialize this rule . Getting error.

deep1234ea avatar Aug 06 '20 20:08 deep1234ea

I'll have a Pull Request for this soon, but to get you working now:

In MRE.cs, add the serializarion attributes to DataRule:

    [DataContract]
    public class DataRule : Rule
    {
        [DataMember]
        public string Type { get; set; }

Include the "known type" in the serializer:

	        var serializer = new DataContractJsonSerializer(typeof(DataRule), new[] { typeof(Rule) });

Also, if Column2 is an int, make it that in the rule:

	        Rule rule = DataRule.Create("Column2", mreOperator.Equal, 123) 
                          & DataRule.Create("Column1", mreOperator.Equal, "Test");

jamescurran avatar Aug 06 '20 21:08 jamescurran

Yes , that works for me.. Thank you so much.

On Thu, Aug 6, 2020 at 5:02 PM James Curran [email protected] wrote:

I'll have a Pull Request for this soon, but to get you working now:

In MRE.cs, add the serializarion attributes to DataRule:

[DataContract]
public class DataRule : Rule
{
    [DataMember]
    public string Type { get; set; }

Include the "known type" in the serializer:

      var serializer = new DataContractJsonSerializer(typeof(DataRule), new[] { typeof(Rule) });

Also, if Column2 is an int, make it that in the rule:

      Rule rule = DataRule.Create("Column2", mreOperator.Equal, 123)
                      & DataRule.Create("Column1", mreOperator.Equal, "Test");

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/runxc1/MicroRuleEngine/issues/25#issuecomment-670190115, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQQ435YCQIRFIA26TWLCXB3R7MK6DANCNFSM4PW52DOA .

deep1234ea avatar Aug 07 '20 13:08 deep1234ea