Пример #1
0
 public DataAccessServiceGeneric(IGetDbContext <TDbContext> getDbContextImpl) : base(getDbContextImpl)
 {
     SetBehaviorOfLoadTuple(new DataAccessGenericImpl <TDbContext, TEntity>(getDbContextImpl));
     SetBehaviorOfAddTuple(new DataAccessGenericImpl <TDbContext, TEntity>(getDbContextImpl));
     SetBehaviorOfModifyTuple(new DataAccessGenericImpl <TDbContext, TEntity>(getDbContextImpl));
     SetBehaviorOfDeleteTuple(new DataAccessGenericImpl <TDbContext, TEntity>(getDbContextImpl));
 }
Пример #2
0
        private static int exec(IToCommand builder)
        {
            IGetDbContext db = builder as IGetDbContext ?? throw new ArgumentNullException(nameof(builder));

            var cmd = builder.ToCommand();

            try
            {
                if (cmd.Parameters != null && cmd.Parameters.Length > 0)
                {
                    return(db.GetDbContext().Database.ExecuteSqlCommand(cmd.Sql, cmd.Parameters));
                }
                else
                {
                    return(db.GetDbContext().Database.ExecuteSqlCommand(cmd.Sql));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "  sql:" + cmd.Sql, ex);
            }
        }
Пример #3
0
 public BaseDataAccessService(IGetDbContext <TDbContext> getDbContextImpl) : base(getDbContextImpl)
 {
 }
Пример #4
0
 public TancleDbContext(IGetDbContext <TDbContext> getDbContextImpl)
 {
     _getDbContext = getDbContextImpl;
 }
Пример #5
0
 public DataAccessGenericImpl(IGetDbContext <TDbContext> getDbContextImpl) : base(getDbContextImpl)
 {
 }