Selecting a specific object in list for a variable value
Posted: Mon Jan 21, 2019 7:44 pm
In the object that I am registering there is a list (I'm registering plain c# classes). I'd like to assign a value to a variable based on a single item in the list. For example if I have a list of 'Fees' that have these properties:
public string Name {get;set;}
public decimal Amount {get;set;}
and I wan't to assign the value of a fee with the name "Fee1" to a variable, how can I do that? If I was using Linq I would do something like: .Single(l => l.Name == "Fee1"), I know Linq isn't supported in expression but how would I do the equivalent?
If there is no means for that, I have also tried adding a DataTable to the base object with the enumeration of the Fees as rows but it looks like I can't add a DataTable as a property to the base c# object. I suppose then I could register a second source that is a DataTable but ideally I could just 'select' the single object in the list.
Thanks,
Brian
public string Name {get;set;}
public decimal Amount {get;set;}
and I wan't to assign the value of a fee with the name "Fee1" to a variable, how can I do that? If I was using Linq I would do something like: .Single(l => l.Name == "Fee1"), I know Linq isn't supported in expression but how would I do the equivalent?
If there is no means for that, I have also tried adding a DataTable to the base object with the enumeration of the Fees as rows but it looks like I can't add a DataTable as a property to the base c# object. I suppose then I could register a second source that is a DataTable but ideally I could just 'select' the single object in the list.
Thanks,
Brian