filter typed view based on another typed view

Posts   
 
    
jspanocsi
User
Posts: 145
Joined: 04-Mar-2005
# Posted on: 22-Dec-2005 15:22:28   

I may have already asked this, if so sorry. This is the second time I hit this. I hacked around the first one but this is going to come up a lot in our app so I need a better solution.

I have a bunch of crystal reports that I need to pass in 2 separate datatables to for the report and subreport.

I made 2 typed views. one is basically the parent records and the other is the children. They are joined by a single field PK to FK. I filter my parent view on it's criteria. How can I filter the child one based off the other typed view? I need all children for all parent records in the parent view?

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Dec-2005 15:50:05   

I made 2 typed views

I get that you have 2 Views in the database, if they are related which is the case, you may map them to 2 Entities (ParentEntity & ChildEntity) and create the relation between them at design time.

Then you may use FetchEntityCollection() to get the collection of the ParentEntity, bind it to the first datagrid,

and then bind the second datagrid to the ChildEntity collection associated with the ParentEntity (field mapped on relation)

For Example:

((ParentEntity)ParentCollection[SelectedItem]).ChildCollection 
jspanocsi
User
Posts: 145
Joined: 04-Mar-2005
# Posted on: 22-Dec-2005 17:31:29   

is there any way to use typed views? I can't do entities as the typed views I have now go across 8 tables or so. I just need to filter the 2nd view based off the first. I will be passing the typed view's into a crystal report after that.

Thanks.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 23-Dec-2005 02:36:51   

Walaa was saying that you can use your database views as entities. You can then define this relationship between those two views as enities, but they will still be using your views that span 8 tables.

jspanocsi
User
Posts: 145
Joined: 04-Mar-2005
# Posted on: 23-Dec-2005 17:59:26   

Now that's cool. i didn't even know you could do that. Thanks, it should work fine.