Filtering an EditableRootList

Filtering an EditableRootList

Old forum URL: forums.lhotka.net/forums/t/2402.aspx


JonWright posted on Thursday, February 22, 2007

Hello, I'm a little unsure of how to implement the following

I have a Student object, Students belong to different schools and also belong on different campuses.

I therefore have two sprocs, the first of which returns all Students for a given School, and the 2nd all for a given school and and given campus.

My query relates to how I would then implement this within my StudentList class.

I am only allowed to have one DataPortal_Fetch(Criteria criteria) method in which the sproc to use is defined, so how can I, or rather what is the best way to allow for the above requirement to be met?

Thanks

Jon

JonWright replied on Thursday, February 22, 2007

Further to this I've currently implemented like this

Within the DataPortal_Fetch method I check to see if the value of one of the Criteria attributes is greater than 0.

If it is I set the Command objects CommandText to one sproc else I set it to the other sproc

Is this the right way to go about doing this kind of thing?

Thanks

Jon

RockfordLhotka replied on Thursday, February 22, 2007

You can have two different criteria classes, and then have two different DP_Fetch() methods, each accepting a specific type of criteria object as a parameter. That might provide more clear separation for calling your different sprocs - though I could see how both DP_F methods might just set up the SqlCommand object and then call a private helper to do the actual work, because I bet (other than the sproc setup) it is the same in both cases.

JonWright replied on Sunday, February 25, 2007

Thanks for the reply Rocky, I went with the simple if/else for the moment but if things get more complex along the way I'll have a look at  extending CriteriaBase.

Jon

Copyright (c) Marimer LLC