locked
EF 6.4 - Partial Class for outstanding balance not getting syntax right RRS feed

  • Question

  • User379720387 posted

    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

    Sunday, May 24, 2020 3:34 AM

Answers

  • User1120430333 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 24, 2020 7:15 AM
  • User-821857111 posted

    && t.ownerBillToId = ownerBillToId

    && (t.ownerBillToId != null && t.ownerBillToId.Value == ownerBillToId)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 24, 2020 9:42 AM

All replies

  • User1120430333 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 24, 2020 7:15 AM
  • User-821857111 posted

    && t.ownerBillToId = ownerBillToId

    && (t.ownerBillToId != null && t.ownerBillToId.Value == ownerBillToId)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 24, 2020 9:42 AM
  • User379720387 posted

    Ended up making the permanent fix in the db, by removing the check mark for "allow null".

    Monday, May 25, 2020 3:16 PM