I have a problem with Entity Framework 4 CTP 5 and I understand that LINQ to SQL handles it better than this, but I insist on using EF 4 because of its Code-First function.
So here is my problem:
Imagine products with your tags (or something like a one-to-one relationship ). And tblTags will change, removing some and inserting some tags at a time by the user (and the user can change them completely differently). Therefore, in my opinion, we can simply delete all the old tags and insert new ones (the simplest things), although this is a simple idea, LINQ to SQL does an excellent job of this, unlike EF 4. Codes for comparing with LINQ:
LINQ to SQL:
Dim oldTags = ctx.Tags.Where(Function(m) m.ProductID = pID)
Dim newTags = 'from user input, like from the model which was posted, like in MVC'
ctx.Tags.DeleteAllOnSubmit(oldTags)
ctx.Tags.InsertAllOnSubmit(newTags)
ctx.SubmitChanges()
EF 4 CTP5:
Dim oldTags = ctx.Tags.Where(Function(m) m.ProductID = pID)
Dim newTags = 'from user input, like from the model which was posted, like in MVC'
For Each item In oldTags
ctx.Tags.Remove(item)
Next
For Each item In newTags
ctx.Product.Add(item)
Next
ctx.SaveChanges()
What I'm trying to do is:
- LINQ to SQL
( , ). .
- Entity Framework ""
"".
EF , , ( ). SQL, .
, , LINQ to SQL .
- SQL. .
, Code-First , LINQ to SQL ( ). ? - EF? LINQ to SQL RTM?
UPDATE
, .
, , , .
, . .