ExpressionGenerator
ExpressionGenerator copied to clipboard
using more complex objects
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"
]
}
]
}