Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > General> how to save related entity?
 

Pages: 1
General
how to save related entity?
Page:1/1 

  Print all messages in this thread  
Poster Message
nevernet
User



Location:

Joined on:
01-Feb-2010 13:21:09
Posted:
67 posts
# Posted on: 04-Mar-2010 05:30:59.  
Code:

bool isNew = false;
            FamiliesEntity ate = new FamiliesEntity(CTid);
            isNew = ate.IsNew;
            ate.UserId = UserId;
            ate.Name = name;
            ate.Description = txtDescription.Text.Trim();
            ate.CreateDateTime = DateTime.Now;
            ate.Save();

            if (isNew)
            {
                FamilyUsersEntity fuentity = new FamilyUsersEntity();
                fuentity.UserId = UserId;
                fuentity.FamilyId = ate.FamlyId;// foreign key
                fuentity.Save();
            }


Is my way right?
but if i have many FamilyUsersEntity , how to save them?
Thank you
Dev Environment as below:
.Net 3.5, LLBLGen Pro 2.6, SQLServer 2008, IIS7
 
Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13799 posts
# Posted on: 04-Mar-2010 10:32:25.  
Code:
            bool isNew = false;
            FamiliesEntity ate = new FamiliesEntity(CTid);
            isNew = ate.IsNew;
            ate.UserId = UserId;
            ate.Name = name;
            ate.Description = txtDescription.Text.Trim();
            ate.CreateDateTime = DateTime.Now;
            //ate.Save();

            if (isNew)
            {
                FamilyUsersEntity fuentity = new FamilyUsersEntity();
                fuentity.UserId = UserId;
                ate.FamilyUsers.Add(fuentity);
            }

            ate.Save(true);


  Top
nevernet
User



Location:

Joined on:
01-Feb-2010 13:21:09
Posted:
67 posts
# Posted on: 04-Mar-2010 13:39:06.  
great

Thank you
Dev Environment as below:
.Net 3.5, LLBLGen Pro 2.6, SQLServer 2008, IIS7
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.