Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
588 views
in Technique[技术] by (71.8m points)

entity framework - ObjectContext.Refresh()?

How to update ALL the dirty entities from the data store, and reset their changed values to the original store value?

The method ObjectContext.Refresh requires as a parameter the entities to be refreshed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The following usually works:

Context.Refresh(RefreshMode.StoreWins, _
    Context.ObjectStateManager.GetObjectStateEntries())

It sometimes causes problems with EntityRelations. look at my comment for further details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...