Recently I had a need in a project to have a few read-only entities because the tables didn't belong to my application. I didn't want to create views into those tables, I just wanted a read-only entity. If we set the entity's state such that it isn't tracked in the ObjectContext, then no changes would ever be persisted for it.
The following allows usage of context.States (ie states of the USA) but doesn't track any changes.
/// Using a dbquery since this is readonly.
/// </summary>
public DbQuery<State> States
{
get
{
// Don't track changes to query results
return Set<State>().AsNoTracking();
}
}
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteIf you are interested in earning money from your traffic via popup ads, you should try one of the most reputable networks - PopAds.
ReplyDeleteBest work you have done, this online website is really cool with great facts. jiofi settings
ReplyDelete