how to do: "select * from personel where personel.NO in (select personelLanguage.NO from personelLanguage)"

Posts   
 
    
Posts: 24
Joined: 01-Dec-2006
# Posted on: 04-Jan-2007 13:22:14   

There are 2 entity collections. First I create language entity collection. There are some information about personel's language. Second one is personel entity collection which have all personels. For example There are 3 person who knows German. I want to filter Personel entity collection with this language entity collection. So I will have individual information for 3 persons who knows german.

There is an example in document. But it is can't use in this case. So how can I do it?

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 04-Jan-2007 14:22:59   

there are a couple different ways to create the information you need. My first question is what is the db schema, and how are your enities related within LLBL? Off the top of my head these 2 examples may work... this assumes a 1:N or M:N relation between language and people.

do you want a collection of languages and their related PeopleEntities such as: 1. English 1.1 Jason 1.2 Mike 1.3 Susan 2. Spanish 2.1 Juan 2.2 Maria this example can be created via a LanguageEntityCollection and PeoplePrefetchPath

Or do you want just a collection of people who speak a specific language (english)? Jason Mike Susan This is simple enough by declaring a new PeopleEntityCollection and New Predicate (PeopleFields.LanguageId == [the language id])

I don't think you would need an "in" clause [CompareSetPredicate()] to get the data you want.

Posts: 24
Joined: 01-Dec-2006
# Posted on: 04-Jan-2007 14:59:05   

-Oracle, .net2005

Here is the example:

Language Collection Table: Id -- language -- Level 1 English 7 2 English 4 3 English 6

People Collection Table: Id -- Name --- ... 1 George ... 2 Mike ... 3 Brad ... 4 Tom 5 Joe

After Operation I want to have people who knows english: Id -- Name --- 1 George 2 Mike 3 Brad

I have done this using for() loop... If you know other way, you can share..

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 04-Jan-2007 15:09:58   

assuming there is a 1:N relation between Language and People the sql would look something like:

select p.* 
from people p inner join langauge l on p.language_id = l.language_id
where l.language = 'English'

the code would look somthing like this. (using the adapter model)

IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(LanguageFields.Language == "English");
filter.Relations.Add(PoepleEntity.Relations.LanguageEntityUsingLanguageId);

EntityCollection peoples = new EntityCollection(new PeopleEntityFactory().Create());
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchEntityCollection(peoples, filter);
}