Tutorial :what does one to one table mapping mean?


I heard this phrase when I was listening to dot net rocks this morning. apparently linq to sql only supports one to one table mapping.


One to one, one to many, many to many are terms that define the multiplicity of relationships.



One-to-one mapping means that one parent row can have only one child row. There are different kinds of mapping when you consider design

One-To-Many: A car has many parts
Many-To-One: Many cars use the same part
Many-To-Many: Many parts are used in many cars
One-To-One: One part is used only once in one car


I know that Linq-to-Sql does allow for not just one to one mapping but also one to many mapping as has been mentioned.

I either haven't heard (or listened to recently) the DNR episode that you mentioned (which one and what time was this quote mentioned). But I find it unlikely that they would mean Linq-to-Sql cannot handle one to many relationships.

I think that they mean that Linq-to-Sql can only do one to one matching on the "entities". So your database can have CUSTOMER and INVOICE as a one to many relationship and in Linq-to-Sql you will have a object called Customer and an object called Invoice where the relationship between them is 1 to many, but the relationship between .NET and the database tables is 1 to 1. To contract Linq-to-Entities can have one to many relationships with their objects, for instance you can have one database table called INVOICE, but you can have multiple Linq objects, for instance Invoice and PaidInvoice and these will both reference the same database table, but PaidInvoice will have the Paid_flg column set to 1 instead of 0.


It means for each entry in one table, there is a single related entry in another table. But, Linq to SQL supports all kinds of data relationships other than one-to-one. Take a look at the Join examples here for example.


One to one relationship means for every record in the one table there is one and only one record in the related table...

But LinqToSql supports mapping of one to one and one to many relationships... Many to many can be accomplished but it requires some coding...

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »