OData

Associate
Joined
27 Jan 2005
Posts
1,312
Location
S. Yorks
I am trying to query Dynamics CRM to return the quote details, so far I can return the quote details for a specific quote, however it returns everything.

Code:
private void BeginRetrieveQuoteDetail(Guid Id)
        {
            dataGrid1.ItemsSource = null;

            _context = new AnconTestContext(ODataUri);

            lstQuoteDetails = new DataServiceCollection<QuoteDetail>(_context);

            var result = from QuoteDetailSet in _context.QuoteDetailSet.Where<QuoteDetail>(r=> r.QuoteId.Id ==Id) select QuoteDetailSet;
          
            lstQuoteDetails.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(lstQuoteDetails_LoadCompleted);
            lstQuoteDetails.LoadAsync(result);

        }

        private void lstQuoteDetails_LoadCompleted(object sender, LoadCompletedEventArgs e)
        {
            if (lstQuoteDetails.Continuation != null)
            {
                lstQuoteDetails.LoadNextPartialSetAsync();
            }
            else
            {
                dataGrid1.ItemsSource = lstQuoteDetails;
            }

        }

How can I get it to return specific columns?

regards,

Matt
 
Associate
OP
Joined
27 Jan 2005
Posts
1,312
Location
S. Yorks
Forgot to add.

If I change line to

Code:
var result = from QuoteDetailSet in _context.QuoteDetailSet.Where<QuoteDetail>(r=> r.QuoteId.Id ==Id) select QuoteDetailSet.BaseAmount;

I get an error at line

Code:
lstQuoteDetails.LoadAsync(result);

Argument 1: cannot convert from 'System.Linq.IQueryable<Microsoft.Crm.Sdk.Samples.CrmODataService.Money>' to 'System.Linq.IQueryable<Microsoft.Crm.Sdk.Samples.CrmODataService.QuoteDetail>'

and

The best overloaded method match for 'System.Data.Services.Client.DataServiceCollection<Microsoft.Crm.Sdk.Samples.CrmODataService.QuoteDetail>.LoadAsync(System.Linq.IQueryable<Microsoft.Crm.Sdk.Samples.CrmODataService.QuoteDetail>)' has some invalid arguments

regards,

Matt
 
Permabanned
Joined
9 Aug 2009
Posts
12,236
Location
UK
you're putting all the stuff from 1stquotedetails into the datagrid, rather than the 'result'

also weird code to debug having a combination of events and linq - would be either if you refactor to use neither
 
Permabanned
Joined
9 Aug 2009
Posts
12,236
Location
UK
in a nasty-hacky way, this might help

Code:
private void BeginRetrieveQuoteDetail(Guid Id)
        {
            dataGrid1.ItemsSource = null;

            _context = new AnconTestContext(ODataUri);

            lstQuoteDetails = new DataServiceCollection<QuoteDetail>(_context);

            //var result = from QuoteDetailSet in _context.QuoteDetailSet.Where<QuoteDetail>(r=> r.QuoteId.Id ==Id) select QuoteDetailSet;
          
            lstQuoteDetails.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(lstQuoteDetails_LoadCompleted);
            //lstQuoteDetails.LoadAsync(result);

        }

        private void lstQuoteDetails_LoadCompleted(object sender, LoadCompletedEventArgs e)
        {
            if (lstQuoteDetails.Continuation != null)
            {
                lstQuoteDetails.LoadNextPartialSetAsync();
            }
            else
            {
var result = from QuoteDetailSet in _context.QuoteDetailSet.Where<QuoteDetail>(r=> r.QuoteId.Id ==Id) select QuoteDetailSet;
                dataGrid1.ItemsSource = result;
            }

        }
 
Associate
Joined
6 Jan 2014
Posts
137
Without going into mass details - Assuming you're trying to make the grid editable and that you're using 2011? Can I ask why you're not just using the OOTB quote-products grid?

Can't help with the C# sadly.
 
Associate
Joined
30 Apr 2004
Posts
50
Can you just use a lamda? Something like:

Code:
private void BeginRetrieveQuoteDetail(Guid Id)
{
    dataGrid1.ItemsSource = null;

    _context = new AnconTestContext(ODataUri);

    lstQuoteDetails = new DataServiceCollection<QuoteDetail>(_context);

    //var result = from QuoteDetailSet in _context.QuoteDetailSet.Where<QuoteDetail>(r=> r.QuoteId.Id ==Id) select QuoteDetailSet;
 
    lstQuoteDetails.LoadCompleted += (sender, e) => {
    	if (lstQuoteDetails.Continuation != null)
    	{
        	lstQuoteDetails.LoadNextPartialSetAsync();
    	}
    	else
    	{
		var result = from QuoteDetailSet in _context.QuoteDetailSet.Where<QuoteDetail>(r=> r.QuoteId.Id ==Id) select QuoteDetailSet;
        	dataGrid1.ItemsSource = result;
    	}
    };
}
 
Associate
OP
Joined
27 Jan 2005
Posts
1,312
Location
S. Yorks
Thanks for the replies guys.

We cannot use the OOB quote as the quote portion of our CRM product is quite complex to say the least.

Another complication is that I have now been asked to look at moving the quote module across to HTML5 - any help on how to get started on this as nothing is appearing in google on how to get started with HTML5 and dynamics crm.

regards,

Matt
 
Back
Top Bottom