Last post May 25, 2020 03:16 PM by wavemaster
Contributor
2613 Points
2724 Posts
May 24, 2020 03:34 AM|wavemaster|LINK
I have a class Transaction and a class Owner that is generated from the database when updating Model.edmx
In addition there are a few customizations on both in a partial classes.
Need to get the Sum of Transaction.Charge for a specific providerId, ownerId with conditions IsBilled= true and IsPaid = false
Cannot figure out if this is an extension on Owner or on Transaction. I would navigate Owner.Transactions
Then the actual code is also resulting in a squiggle:
public decimal outstandingBalance(List<Transaction> transactions, int providerId, int ownerBillToId) { var balance = transactions .Where(t => t.ProviderId = providerId && t.ownerBillToId = ownerBillToId && t.IsBilled && t.IsPaid = 0) .Charge.Sum(); return (decimal)balance; }
squiggles are on = providerId and = ownerBillToId with a complaint about operator && cannot be used with int? and int
4963 Points
4218 Posts
May 24, 2020 07:15 AM|DA924|LINK
You may have to implement code for using the nullable types and null coalescing operators.
https://dzone.com/articles/nullable-types-and-null-coalescing-operator-in-c
But I would also say that whatever property is nullable see if you can remove the nullable off of it.
All-Star
194525 Points
28083 Posts
Moderator
May 24, 2020 09:42 AM|Mikesdotnetting|LINK
wavemaster && t.ownerBillToId = ownerBillToId
&& t.ownerBillToId = ownerBillToId
&& (t.ownerBillToId != null && t.ownerBillToId.Value == ownerBillToId)
May 25, 2020 03:16 PM|wavemaster|LINK
Ended up making the permanent fix in the db, by removing the check mark for "allow null".
Contributor
2613 Points
2724 Posts
EF 6.4 - Partial Class for outstanding balance not getting syntax right
May 24, 2020 03:34 AM|wavemaster|LINK
I have a class Transaction and a class Owner that is generated from the database when updating Model.edmx
In addition there are a few customizations on both in a partial classes.
Need to get the Sum of Transaction.Charge for a specific providerId, ownerId with conditions IsBilled= true and IsPaid = false
Cannot figure out if this is an extension on Owner or on Transaction. I would navigate Owner.Transactions
Then the actual code is also resulting in a squiggle:
squiggles are on = providerId and = ownerBillToId with a complaint about operator && cannot be used with int? and int
Contributor
4963 Points
4218 Posts
Re: EF 6.4 - Partial Class for outstanding balance not getting syntax right
May 24, 2020 07:15 AM|DA924|LINK
squiggles are on = providerId and = ownerBillToId with a complaint about operator && cannot be used with int? and int
You may have to implement code for using the nullable types and null coalescing operators.
https://dzone.com/articles/nullable-types-and-null-coalescing-operator-in-c
But I would also say that whatever property is nullable see if you can remove the nullable off of it.
All-Star
194525 Points
28083 Posts
Moderator
Re: EF 6.4 - Partial Class for outstanding balance not getting syntax right
May 24, 2020 09:42 AM|Mikesdotnetting|LINK
Contributor
2613 Points
2724 Posts
Re: EF 6.4 - Partial Class for outstanding balance not getting syntax right
May 25, 2020 03:16 PM|wavemaster|LINK
Ended up making the permanent fix in the db, by removing the check mark for "allow null".