Multiple where condition in following code result in only first row displaying,
public bill_transaction Getbill_transaction(int id)
{
bill_transaction bill_transaction = db.bill_transaction.Where(m => m.Cust_Id == id && m.Bill_Status == "P").FirstOrDefault();
if (bill_transaction == null)
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
}
return bill_transaction;
}
i want to display all rows matching with this condition,
even for single condition also, first row only displying, how i can display all rows.
Just remove
FirstOrDefault
, also that's why the next checkbill_transaction == null
is performed. So looks like you also want to remove that check, the return type is also not justbill_transaction
, it should beIQueryable<bill_transaction>
orIEnumerable<bill_transaction>
. Sum up all we have this simple new method:Note if there is not any transaction, an exception is thrown (this behavior is up to you).