Search code examples
c#databaseforeign-keysdatarelation

Is it possible to create DataRelation 1:1 in c#?


In my app I use ORM Designer which supports only 1:1 relation. I have Items, Products, Shipping tables: Item has ProductId and ShippingId attributes which are foreign keys.

I need to upload data from xml file into my SQL DB, so I gonna use SqlBulkCopy class and I need to create DataTable objects: itemsTable, productsTable, shippingTable to load data from xml into them.

So, do I need to create DataRelations: ItemsProducts and ItemsShipping? If so, itemsTable would contain productsTable and shippingTable?

Thanks!

Edits:

And is it possible to write to server the content from 3 dataTables simultaneously?


Solution

  • This isn't a direct answer to your question, but it's entirely possible to have a one-to-many relationship in a .dbml file. See the screenshot below, which is simply the properties sidebar you can get to by right-clicking on an association and choosing "Properties".

    enter image description here