This project is read-only.
  • ManyToOne : The many to one is straight forward, meaning many instances of the current object to one instance of the related object. If you reverse the code above, you will see that many instances of the CustomeOrders are to one instance of the customer. Let me give you a green light on this by illustrating with another code.

                 //This is CustomerOrders class
        [ManyToOne(typeof(Customer), RelationColumn = "CustomerId")]
        public virtual Customer Customer

You see, we would have expected that the CustomerId value that is bound to the RelationColumn should come from the customer, but we are wrong, since we are saying Many CustomerOrders to Customer, in reality, the CustomerOrders table will hold the foreign key to the Customer table. So the framework will look in the CustomerOrders table for the “CustomerId” column. By relational convention, we are doing the right thing.

Last edited Feb 23, 2010 at 2:32 PM by ahmedsalako, version 1


No comments yet.