I have this Linq expression that works well. What is the right approach to test if it has returned anything?
internal static void getCreditNotes(string invoiceId, out DataTable creditNotes,out double total)
{
total = 0;
creditNotes = new DataTable();
var q = dt.AsEnumerable().
Where(r =>
(string) r["invoiceId"] == invoiceId
&& (string) r["TransactionType"] == "CreditMemo");
creditNotes = q.CopyToDataTable();
total = creditNotes.AsEnumerable().Sum(r => (double) r["TransactionAmount"]);
This code breaks on line 9 (q.CopyToDataTables) when there are no rows. I could use a try catch but that seems a bit of an overkill.