iCodeSometime
iCodeSometime

Reputation: 1662

Entity Framework Update Table with only keys

I've got two keys, and want to update the foreign keys in a single query, without pulling it out first(for efficiency reasons)

In other words, I'm wondering if there's any way to run the following query with entity

UPDATE User_Conversation
SET LastReadMessageId = @lastReadMessageId
WHERE Id = @userConversationId
AND UserId = @currentUserId -- for security

Upvotes: 0

Views: 37

Answers (1)

Amir
Amir

Reputation: 1274

You can use "Attach" function with State=Modified for fields that you want to update.

Check here for more information.

Upvotes: 1

Related Questions