Batch insert/update with entity framework

前端 未结 1 1770
长情又很酷
长情又很酷 2021-01-06 06:59
  1. I have a Tags table whose schema consists of only ID and Name (unique). Now, from the GUI user can enter tags for a BlogPost. When the data is saved, with tags st

相关标签:
1条回答
  • 2021-01-06 07:12

    I don't believe the Entity Framework does batch inserts at all (at present). So if you must keep the number of DB roundtrips so low, you're probably going to have to use a stored procedure or a database trigger. Fortunately, the Entity Framework supports stored procedures which return entity types. There is documentation on MSDN about this. You could create a proc which accepts a string list of tags and returns tag entity instances. Alternately, you could add a VARCHAR column to your post table for a delimited list of tags, and parse it in the trigger.

    0 讨论(0)
提交回复
热议问题