c# - Entity Framework Code First Updating with Where Clause -


I am automatically using data from the currently logged user of my system. It provides me with a dynamic way to return data from the current user and does not reach other user data.

I am updating one unit, I would like to do the same. I can get the unit from the database with FilteredSet and if the entity does not have the ID thrown an exception but I prefer to first load the unit and not only attach this one more update.

So far, I have tried:

  Public Zero UpdateOwnable & LT; TEntity & gt; (TEntity unit) where TENTity:. Square, IEtity, IUserOwnable {var entityLocal = SetOwnable & LT; TEntity & gt; () Local.SingleOrDefault (D = & gt; DID == Unit ID); If (entityLocal == zero) {entityLocal = This. SetOwnable & lt; TEntity & gt; (). Attached (unit); } This.ChangeTracker.Entries & LT; TENTity & gt; () Single (d = & gt; d.Entity == entityLocal) .State = EntityState.Modified; }   

The problem is that the generated query does not contain a WHERE volume. I hope to find a way from where it is not only the primary key of the unit but also the User ID. Update workout SET name .. Where id = 1 and idUser = 123;

This is SQL query that I want to do the unit framework to generate. With a "and" section for IdUser

Could this be possible?

itemprop = "text">

EF does not provide out-of-the-box performance to add to where the box functionality . The difference you can use from this open source project for example is that your update the SaveChanges call (because the EF does not support it) will not be part of

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -