Exemplo n.º 1
0
        //public static IQueryable<TEntity> Select<TEntity>(this IQueryable query)
        //{
        //    if (query == null)
        //    {
        //        throw new ArgumentNullException(nameof(query));
        //    }
        //    return query.ProjectTo<TEntity>();
        //}

        #region 动态执行Sql语句扩展
        /// <summary>
        /// 执行sql命令
        /// </summary>
        /// <example>ExecuteSqlCommandEx("delete from [Table] where ID=@0", Guid.Empty)</example>
        /// <param name="database">数据库对象</param>
        /// <param name="sql">sql语句</param>
        /// <param name="values">参数值</param>
        /// <returns></returns>
        public static int ExecuteSqlCommandEx(this Database database, string sql, params object[] values)
        {
            var param = QueryableExtensions.MakeSqlParameter(sql, values);

            return(database.ExecuteSqlCommand(sql, param));
        }