예제 #1
0
        public long Insert <TEntity>(TEntity entity) where TEntity : class
        {
            SetCommonAddProperty(new object[] { entity });

            string sql = SQLBuilder.BuildAddSql <TEntity>(MyContext.GetTableName(typeof(TEntity)), entity).ToString();

            long id = Convert.ToInt64((ExecuteScalar(sql).ToString()));

            ReflectionUtil.SetPropertyValue(entity, "id", id);

            return(id);
        }
예제 #2
0
        public int InsertNoId <TEntity>(IEnumerable <TEntity> entitys) where TEntity : class
        {
            if (entitys == null || entitys.Count() <= 0)
            {
                return(0);
            }

            SetCommonAddProperty(entitys.ToArray());

            string sql = SQLBuilder.BuildAddSql <TEntity>(MyContext.GetTableName(typeof(TEntity)), entitys).ToString();

            return(ExecuteNonQuery(sql));
        }