-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: How to get the particular rows from the IList
PostPosted: Tue Apr 11, 2006 3:12 am 
Newbie

Joined: Mon Apr 03, 2006 2:04 am
Posts: 4
Hi,

i hava a list of values in my IList.
i want to show only particular rows in my grid from that list.
how to get only selected rows from the list.
please help me regarding this.

Thanks,
Murali


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 3:57 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Hi MuraliAluri,

From the NHibernate documentation:

Quote:
9.3.3. Filtering collections

A collection filter is a special type of query that may be applied to a persistent collection or array. The query string may refer to this, meaning the current collection element.

Code:
ICollection blackKittens = session.Filter(
    pk.Kittens, "where this.Color = ?", Color.Black, NHibernateUtil.Enum(typeof(Color))
);


The returned collection is considered a bag.


Does that help?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 8:24 am 
Newbie

Joined: Tue Mar 21, 2006 4:18 pm
Posts: 11
This is not exact answer. Filter method search in collection, which is binded to some class. But what about situation, when IList is result of some Criteria query, it means without "master" object. Could you still use Filter method? In my opinion not.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 10:00 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I see your point. The answer is...not that I'm aware of. If you want a specific subset of data that's not from a persistent collection then you'd probably need to query for it explicitly (which is in effect what the .Filter method does internally - it's creating a new SQL query and adding the additional criteria specified to the normal criteria used to get the collection); eg. perform another Criteria query that includes the additional criteria you need to get the specific subet of data you need.

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 11:11 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
agree with merge. only other option would be to use a foreach loop in your code to check for the particular condition (row) you are looking for:

Code:
ArrayList matchedObjects = new ArrayList();

foreach (Object obj in myListOfQueriedObjects) {
    if (obj.Property == someCondition) {
        matchedObjects.Add(obj);
    }
}

DataGrid myDG;
myDG.DataSource = matchedObjects;
myDG.DataBind();


however, this really isn't good OO design. business logic now sits in the presentation layer...

-devon


Last edited by devonl on Tue May 16, 2006 11:48 am, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 11:32 am 
Newbie

Joined: Tue Mar 21, 2006 4:18 pm
Posts: 11
devonl wrote:
only other option would be to use a foreach loop in your code to check for the particulkar condition (row) you are looking for:


Yes, i have discovered it also. The goal was filter existing data without asking database again and again.

[/quote]
however, this really isn't good OO design. business logic now sits in the presentation layer...
-devon[/quote]

You are still able to put this code to some class in your business layer, like other app logic which have nothing to do with database.
Bye.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 12:45 pm 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
devonl wrote:
however, this really isn't good OO design. business logic now sits in the presentation layer...


Without knowing the problem at hand You can't be sure. It might be purely presentation logic.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 3:27 pm 
Beginner
Beginner

Joined: Thu May 12, 2005 2:14 am
Posts: 33
Location: Sweden, Sk
Hi

Maybe npath can help you.. You can download a small demo from this url, http://blogs.wdevs.com/phirephly/archiv ... 12096.aspx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.