question on database with constraint

Thread is closed for posting
2 posts, 0 answers
  1. alain
    alain avatar
    1 posts
    Member since:
    Jan 2011

    Posted 29 Jan 2011 Link to this post

    hi, first time here..
     i have a project with sqlserver database but no reference foreign key. So now i have changed my project to add the constraint of reference with foreign key to the database tables as below:. e.g.

     ALTER TABLE Staffs



    But i don see the benefit after i added the foreign key.. the tables are all linked up now in my .dbml but when i try to write this..

    this.Users.Staff , the staff is always null ... do i still have to initialize that staff eventhough all tables are already linked up?

    In my Users.cs form,
    1) Do i still have to declare  public Staff Staff { get; set; } in Users class?
    2) Do i have to initialize the this.Staff in OnCreated? 

    Also partial void OnCreated()
                this.Staff = new Staff();
                //this.CourseTutor = new CourseByTutor();
               // this.CourseUserStatus = new CourseUserStatuse();
                //this.Payment = new Payment();
                //this.Payment.SaleOrderItem = new SaleOrderItem();
                //this.Payment.SaleOrderItem.SaleOrder = new SaleOrder();
                //  this.SaleOrder = new SaleOrder();

    All the commented code are written previously before i add reference after i add the reference foreign key, do i still need that?
  2. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 03 Feb 2011 Link to this post

    Hello alain,

    I was unable to reproduce this behavior with Telerik OpenAccess ORM and it seems that you are using a Linq to Sql model (.dbml file). In this case maybe you should contact the Microsoft Support regarding the issues you are facing, they should be able to help you.

    Damyan Bogoev
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Back to Top