Associate
- Joined
- 27 Jan 2005
- Posts
- 1,373
- Location
- S. Yorks
I have the following code
It all works as expected however one of the returned values in the query is a null how can I filter these out or deal with these, not touched programming for a short while and cant seem to crack this.
regards,
Matt
Code:
using (GeneratedCode orgcontext = new GeneratedCode(service))
{
var retrievedProducts = (from p in orgcontext.ProductSet
join qd in orgcontext.QuoteDetailSet
on p.ProductId equals qd.sp_SellingProductId.Id
where qd.QuoteId.Id == entity.Id && p.orb_ParentProductid != null
select new
{
product_name = p.orb_ParentProductid.Name
}).Distinct();
var _txttowrite = string.Empty;
if (retrievedProducts != null)
{
// for each item returned write the output to a string.
foreach (var item in retrievedProducts)
{
if (item.product_name != "")
{
if (String.IsNullOrEmpty(_txttowrite))
{
_txttowrite = item.product_name;
}
else
{
_txttowrite += ", " + item.product_name;
}
}
}
}
// Write data to current quote.
Quote currentQuote = (Quote)service.Retrieve(Quote.EntityLogicalName, entity.Id, new ColumnSet(false));
currentQuote.ancon_quoteproducts = _txttowrite;
currentQuote.ancon_activatedate = DateTime.Now;
service.Update(currentQuote);
}
}
It all works as expected however one of the returned values in the query is a null how can I filter these out or deal with these, not touched programming for a short while and cant seem to crack this.
regards,
Matt