Entity Framework: check existence of record before inserting a new one
In my web app a user can assign muliple tags to products (like the tagging here on stackoverflow). There are three tables: products, tags and products_tags to implement a many to many relationship.
My question is, how would you implement this with the Entity Framework (LINQ to SQL): "Insert only a new tag in the tags table if it doesnt already exist there". So before the insert i have to check first if a t开发者_Go百科ag exists, whats the best way to accomplish this (best performance) ??
thanks for answers
Simple: The Tag should then be the user assigned key/PK of the entity/table.
If you have troubles synchronizing this with the database, I am sure there's something like (N)Hibernate's merge Method in EntityFramework.
精彩评论