How to create single Entity from multiple Tables

Posts   
 
    
Posts: 7
Joined: 18-Aug-2010
# Posted on: 29-May-2011 12:02:51   

Hello, Say I have 2 tables Users and Workers

In Users I have: UserId DateAdded DateLastLogin Password Email

In Workers I have WorkerId UserId Name LastName DateBirth

As you see there is a relation between Workers and Users table (Workers.UserId=Users.UserId). In stead of creating 2 Entities I would like to have only one Entity named Workers in which I would like to have all fields from within Users table. How can I create a such entity using LlblGen Pro code generator.

Version: 3.1 using Adapter mode. Language C# DB: Sql Server 2008

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-May-2011 23:01:00   

Hi there,

I assume the Users - Workers relationship is 1:m. There is no way to merge those entities into one. You can however add fields mapped onto related entities. That means you can add User's fields in the Worker entity.

In generated code, you can access the User object through the worker entity like

worker.User.SomeField...

If you add fields mapped onto User entity you can access those fields directly:

worker.SomeFieldInUser...

If you want a custom mixed entity you could create a DB view and map that view into an entity as well.

David Elizondo | LLBLGen Support Team
Posts: 7
Joined: 18-Aug-2010
# Posted on: 30-May-2011 07:14:44   

How about creating TypedList ? In this case I know my TypedList is going to be read only. Am I right ?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-May-2011 11:12:21   

TypedList is read-only indeed.