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
Selecting a specific object in list for a variable value
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Selecting a specific object in list for a variable value
Hello,
Sorry, maybe we did not exactly understand your question. You can use Linq in your code and provide value for the variable.
Thank you.
Sorry, maybe we did not exactly understand your question. You can use Linq in your code and provide value for the variable.
Thank you.
Re: Selecting a specific object in list for a variable value
Yes, I can use Linq in my code in our application but I am trying to use something similar in the expression for a stimulsoft report variable's value. I would like to 'select' a specific item out of a list within the Stimulsoft expression for a variable.
If, in my code I have a list like this:
class Fee {
public string Name {get;set;}
public decimal Amount {get;set;}
}
var listOfItems = new List<Fee>{ new Fee{Name = "Fee1", Amount =100}, new Fee{Name = "Fee2", Amount = 200} }
Then if I register that list for a report using: RegData("Data", listOfItems)
Then, in the report designer I create a new variable and I want that variable's value to be a particular one on that list, let's say the one with the name of "Fee1" can I do that?
Hopefully that makes more sense.
Thanks,
Brian
If, in my code I have a list like this:
class Fee {
public string Name {get;set;}
public decimal Amount {get;set;}
}
var listOfItems = new List<Fee>{ new Fee{Name = "Fee1", Amount =100}, new Fee{Name = "Fee2", Amount = 200} }
Then if I register that list for a report using: RegData("Data", listOfItems)
Then, in the report designer I create a new variable and I want that variable's value to be a particular one on that list, let's say the one with the name of "Fee1" can I do that?
Hopefully that makes more sense.
Thanks,
Brian
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: Selecting a specific object in list for a variable value
Hello,
Directly in the designer, it is not possible.
Thank you.
Directly in the designer, it is not possible.
Thank you.