How to perform a C# CRUD with Mysql and ADO

Asked

Viewed 523 times

1

I need to do the relationship between tables 1:N and N:N.

Table produto:

public int id {get; set;}
public string produto {get; set;}
public list<tamanhos> tamanhos {get; set;}

Table tamanhos:

public int produto_id {get; set;}
public string tamanho {get; set;}

Products can have numerous sizes. How to make a CRUD in Mysql in C# within this scenario? I know how to do all CRUD operations for single tables or 1:1.

  • 1

    What have you tried to do? The way your question is it will be closed.

1 answer

0

Lucas, in this case you will have to have a CRUD for Sizes, Sizes must be registered before you try to register a Product. In product you will only reference the sizes, in this case it will be a relationship N:N and in the database you will need a third table to maintain this relationship. In the Size table you will register the sizes, then in the Products table you register the products and there should be a Products table where you will be informed the Product Id and the Size Id, something similar to Sales and Itensvenda which is a well known example.

  • Thank you very much!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.