Created
February 25, 2020 09:41
-
-
Save mesuttalebi/63e014bb36fb99d3a7f6f87e55d35811 to your computer and use it in GitHub Desktop.
GetByIdNotracking Method added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual T GetByIdNoTracking(params object[] id) | |
{ | |
_context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; | |
var item = DbSet.Find(id); | |
if (item != null) | |
if (typeof(ISoftDeleteEnabled).IsAssignableFrom(typeof(T))) | |
item = (bool)typeof(T).GetProperty("IsDeleted").GetValue(item) == false ? item : null; | |
_context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll; | |
return item; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment