Wednesday

Linq to SQL C# linq join example


try{
LinqDataObjectsDataContext dc = new LinqDataObjectsDataContext();

/* select * from invoice inner join AccountInvoices on
* invoice.cust= AccountInvoices.cust and invoice.sub = AccountInvoices.sub
*/

StringBuilder sb = new StringBuilder();
sb.AppendFormat("<Invoices customer='{0}' sub='{1}'>", cust, sub);

var ret = from invoice in dc.Invoices
join accountInvoice in dc.AccountInvoices on
invoice.InvoiceID equals accountInvoice.InvoiceID
where accountInvoice.SubID ==sub && accountInvoice.CustomerID ==cust
select invoice;

foreach (Invoice i in ret){
sb.Append(CXMLConv.toXML(i));
}

sb.AppendLine("</Invoices>");
return OK(sb.ToString());
} catch (Exception ex) {
return RegisterError(ex, "getInvoicesXML","cust/sub"+cust+"/"+sub);
}

more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...