Re: How To retrieve the Relationsships from an entity in Core Data
Re: How To retrieve the Relationsships from an entity in Core Data
- Subject: Re: How To retrieve the Relationsships from an entity in Core Data
- From: mmalcolm crawford <email@hidden>
- Date: Thu, 15 Dec 2005 23:53:10 -0800
On Dec 15, 2005, at 11:41 PM, Janakiram wrote:
Hi,
I am a new bie to core data. I have two entities names employee &
department. I have a relation, in employee , named departments
which specifies the departments in which the employee works. I can
create employees & departments.But i am unable to retrieve the
employees who r having salaries greater than $10,000 present in a
given department. I don't have a relationsship from department to
employee. I think , i am probably missing the predicate for the
fetch request. Below is the Code for the fetch request.
In general, not defining inverse relationships is strongly discouraged.
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Employee"
inManagedObjectContext:managedObjectContext];
NSFetchRequest *aRequest = [[NSFetchRequest alloc] init];
[aRequest setEntity:entity];
[aRequest setPredicate:[NSPredicate predicateWithFormat:@"salary
>= %f and departments.DeptID == %@ ",10000.0,2]]; // where dept id
is 2.
Use 'ANY':
<
http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/
Articles/pUsing.html#//apple_ref/doc/uid/TP40001794-
DontLinkElementID_10>.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden