示例#1
0
        public static void DetachLocal <T>(this ModelsContext context, T t, int entryId)
            where T : class, IIdentifier
        {
            var local = context.Set <T>()
                        .Local
                        .FirstOrDefault(entry => entry.ProductId.Equals(entryId));

            if (local != null)
            {
                context.Entry(local).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
            }
            context.Entry(t).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
        }
示例#2
0
 public virtual async Task Create(TEntity entity, string createdBy = null)
 {
     await context.Set <TEntity>().AddAsync(entity);
 }