Print Page | Close Window

Pulling my hair out with ObjectDataSources...

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3438
Printed Date: 13-May-2026 at 6:26am


Topic: Pulling my hair out with ObjectDataSources...
Posted By: markfinch
Subject: Pulling my hair out with ObjectDataSources...
Date 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



Replies:
Posted By: sbelini
Date 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 http://drc.ideablade.com/xwiki/bin/view/Documentation/query-paging#HEntityQueryPager - http://drc.ideablade.com/xwiki/bin/view/Documentation/query-paging#HEntityQueryPagedCollectionView - There you will also find several http://drc.ideablade.com/xwiki/bin/view/Main/Search?text=objectdatasource&x=0&y=0 - ObjectDataSources samples .
 
Regards,
   Silvio.


Posted By: markfinch
Date 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



Print Page | Close Window