New Posts New Posts RSS Feed: Pulling my hair out with ObjectDataSources...
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Pulling my hair out with ObjectDataSources...

 Post Reply Post Reply
Author
markfinch View Drop Down
Newbie
Newbie


Joined: 21-Jan-2012
Location: Sheffield UK
Posts: 5
Post Options Post Options   Quote markfinch Quote  Post ReplyReply Direct Link To This Post Topic: Pulling my hair out with ObjectDataSources...
    Posted: 13-May-2012 at 9:22am
Hi everyone,
 
I really hope someone can help with this issue I am having. It seems to me that the objectdatasource is very limited.
 
I am trying what I think to be very simple, I have a customer details page, in the page is a datagrid of related contacts Customer.Customers_Contacts and I wanted to use the objectdatasource to view only the 'active' contacts for that customer.
 
Firstly I cannot assign my own query that is independant of the entitymanager ie Customer_Contacts.where(x => x.Inactive = false && x.CustomerID = customerid) I wanted to extend the customer entity and add a "FilteredContacts" query and bind this to the query parameter
 
 
Secondly failing step one I decided to try and use filterdescriptors on the objectdatasource to specify;
 

ib:FilterDescriptor PropertyPath="CustomerID" Operator="IsEqualTo" Value="{Binding CustomerID}" >

This would then substitute my current customers id into the filter (CANNOT HAVE A BINDING FOR VALUE)
 
Thirdly it seems that you cannot filter on a non-string property, (forgetting customerid) every time I try to filter on InActive (bool);
 

ib:FilterDescriptor PropertyPath="InActive" Operator="IsEqualTo" Value="false" >

The resultant query to the entity manager has disregarded by filter and simply queries all contacts???
I really hope there is a solution to this, can anyone shed some light before I pull out all of my hair :)
Thanks
Mark


Edited by markfinch - 13-May-2012 at 9:24am
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 15-May-2012 at 12:14pm
Hi Mark,
 
Regarding your concerns:
 
1 - You could set the query in code instead:
 
_myDataSource.Query = mgr.Products.Where(prod => prod.ProductID == ProdID);
 
 
2 - Unfortunatelly this is not yet possible. I will add a feature request for it.
 
3 - I was able to filter on a boolean property without any problems: (tested with NorthwindIB.Products.Discontinued property)
 
<ib:FilterDescriptor PropertyPath="Discontinued" Operator="IsEqualTo" Value="true" />
 
Have you considered using a EntityQueryPager or EntityQueryPagedCollectionView instead? They are more robust and provide more functionality. You can find EntityQueryPager Samples and EntityQueryPagedCollectionView Samples in the DRC.
There you will also find several ObjectDataSources samples.
 
Regards,
   Silvio.
Back to Top
markfinch View Drop Down
Newbie
Newbie


Joined: 21-Jan-2012
Location: Sheffield UK
Posts: 5
Post Options Post Options   Quote markfinch Quote  Post ReplyReply Direct Link To This Post Posted: 16-May-2012 at 9:13am
Hi Silvio,
 
Thanks for the quick response. I had implemented your first suggestion "ondatacontextchanged" which solved some of my problems and then got stuck again with viewing large lists of data e.g. a Customer has 30000 assets for instance.
 
I still had no luck with the boolean filter but I will definately look into the EntityQueryPager as I think this will solve my issue. Especially as I need to page across both the server side and cached entities at the same time which I know the objectdatasource doesnt handle.
 
I will let you know how I get on...
 
Thanks for all your help
 
Mark
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down