ExpressionGenerator icon indicating copy to clipboard operation
ExpressionGenerator copied to clipboard

using more complex objects

Open jeffreypolk opened this issue 3 years ago • 0 comments

Very interesting post and sample code! How might this be adapted to handle a more complex object with sub-objects and lists of objects? For example:

namespace ExpressionGenerator
{
    public class Transaction
    {
        public int Id { get; set; }
        public string Category { get; set; }
        public string TransactionType { get; set; }
        public string PaymentMode { get; set; }
        public decimal Amount { get; set; }
        public CostCenter CostCenter { get; set; }
        public List<Approver> Approvers { get; set; }
    }
    public class CostCenter
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Region { get; set; }
    }
    public class Approver
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

}

and perhaps a json like:

{
  "condition": "and",
  "rules": [
    {
      "label": "Cost Center Region",
      "field": "CostCenter.Region",
      "operator": "equal",
      "type": "string",
      "value": "US-EAST"
    },
    {
      "label": "Approver",
      "field": "Approvers.Name",
      "operator": "in",
      "type": "string",
      "value": [
        "Jeremy",
        "Jeff"
      ]
    }
  ]
}

jeffreypolk avatar Mar 05 '21 23:03 jeffreypolk