c# - How could I use Func to modify a single condition of a lambda -
Text after "
I have a simple method containing a query to calculate some values.
Personal Decimal MyQueryBuilderMethod ( MyThings of the list) {return myThings.Where (x => x.Id == 1). Selection (X = & gt ; (x.ThisValue * x.That)) .sum (); } My intention is to modify this method that I have x Allow this value field to allow the object to be asked in the object.
If I specify where my query is, I might pass a predicate but in this case, I just want to change the value of x.ThisValue
Personal Decimal MyQueryBuilderMethod (Listings. ThingsViewModel & gt; MyThings; ThingsViewModel, bool & gt; predicates of the ceremony) Return my myths. Where (predicates) Select (x = & gt; (x.ThisValue * x.That). .Sum (); } Ideally, I want to pass in something like: (things, x.ThisOtherValue)
MyQueryBuilderMethod After
should work:
Personal Decimal MyQueryBuilderMethod ( & Lt; ThingsViewModel & gt; MyThings for the list & lt; ThingsViewModel, Decimal & gt; (; x.Id == 1) .sum (X => (thisValue (x) * x.That X for the list = & gt;) thisValue) {myThings.Where to return; } I also select (...). Less (but) by equivalent Sum (...) >. Then you can call it like this:
var results = MyQueryBuilderMethod (My Things, T = & gt; T. this value);
Comments
Post a Comment