public static EntityEntry CheckInsert(this EntityEntry entity, IPrincipal principal) { var entityPropertys = typeof(ICreationAudited <>).GetProperties(); foreach (var item in entityPropertys) { var entityProperty = entity.GetType().GetProperties().Where(x => x.Name == item.Name).FirstOrDefault(); if (entityProperty != null) { //entityProperty.SetValue(entityProperty.Name,principal.Identity.GetUesrId<>) } } var creationAudited = entity.GetType().GetInterface(/*$"ICreationAudited`1"*/ typeof(ICreationAudited <>).Name); if (creationAudited == null) { return(entity); } entity.CheckICreatedTime(principal); return(entity); }