getmulti() in a collection in an entitity

Posts   
 
    
Homer00
User
Posts: 10
Joined: 27-Dec-2010
# Posted on: 27-Dec-2010 22:06:35   

Hello,

I have three tables 'student', 'teacher' and 'identity'. Each student have an identity and each teacher have an identity too. I need to search information filtered related to 'identity', but only refered to teachers or only refered to students.

what i need is something like identity.students.getmulti(name=='jhon')I get locked.

I'm using self servicing

thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Dec-2010 05:13:57   

I think right now you can do that this way:

// the identity is of an student
if (identity.Students.Count >0)
{
     StudentEntity theStudent = identity.Students[0];
}

// the identity is of an teacher
if (identity.Teachers.Count >0)
{
     TeacherEntity theTeacher = identity.Teacher[0];
}

This assumes you have no uniqueConstraint in the Student or Teacher tables for the identityId, otherwise, you can fetch single records:

// the identity is of an student
if (identity.Student != null)
{
     StudentEntity theStudent = identity.Student;
}

// the identity is of an teacher
if (identity.Teacher != null)
{
     TeacherEntity theTeacher = identity.Teacher;
}

Is this what are you looking for? Do you want to use inheritance (having an StudentIdentityEntity or a TeacherIdentityEntity)?

What LLBLGen version are you using?

David Elizondo | LLBLGen Support Team
Homer00
User
Posts: 10
Joined: 27-Dec-2010
# Posted on: 28-Dec-2010 10:58:17   

Hello Daelmo,

I'm using LLBLGEN 3.0

The code you have post is just for one entity. I need to retrieve all students (entity collection) that have the property 'Name' == 'Jhon' (remember than the property Name is in the entity 'Identity' not in the 'Student' entity

in SQL I need something like:

**SELECT s., i. **FROM **student s, identity i **WHERE **i.ID_identidad=s.ID_identidad **AND **i.Name='Jhon'

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Dec-2010 11:13:28   

I need to retrieve all students (collection entity) that have the property 'Name' == 'Jhon' (remember than the property Name is in the entity 'Identity' not in the 'Student' entity

in SQL I need something like:

SELECT s., i. FROM student s, identity i WHERE i.ID_identidad=s.ID_identidad AND i.Name='Jhon'

I assume there is no inheritance relation between Student and Identity.

var filter = new PredicateExpression(IdentityFields.Name == "Jhon");
var relation = new RelationCollection();
relation.Add(StudentEntity.Relations.Identity...);

var students = new StudentsEntityCollection();
students.GetMulti(filter, relation);
Homer00
User
Posts: 10
Joined: 27-Dec-2010
# Posted on: 28-Dec-2010 11:22:06   

Thank you Walaa!!!,

I've try that code and works!!!. So much thanks!

Is there any book, Pdf tutorial or something out there??? i need it as eat.

thanks, thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Dec-2010 11:42:57   

Other than the online docs: http://www.llblgen.com/documentation/ There are downloadable PDF versions in the download section of our website.