Exemplo n.º 1
0
        public async Task <Category> GetByIDAsync(int id)
        {
            string sql = @"SELECT Id
                                ,Name
                            FROM category
                            WHERE Id = @Id";

            return(await _context.QueryFirstOrDefaultAsync <Category>(sql, new { Id = id }));
        }
Exemplo n.º 2
0
        public async Task <Products> GetByIDAsync(int id)
        {
            string sql = @"SELECT ProductID
                            ,ProductName
                            ,QuantityPerUnit
                            ,UnitPrice 
                            ,CategoryID
                        FROM Products
                        WHERE ProductID = @ProductID";

            return(await _context.QueryFirstOrDefaultAsync <Products>(sql, new { ProductID = id }));
        }
Exemplo n.º 3
0
        public async Task <Product> GetByIDAsync(int id)
        {
            string sql = @"SELECT Id
                                ,Name
                                ,Quantity
                                ,Price 
                                ,CategoryId
                            FROM Product
                            WHERE Id = @Id";

            return(await _context.QueryFirstOrDefaultAsync <Product>(sql, new { Id = id }));
        }
 public async Task <UserAddress> GetByIdAsync(int id)
 {
     return(await _context.QueryFirstOrDefaultAsync <UserAddress>("SELECT * FROM UserAddress WHERE Id=@Id", new { Id = id }));
 }
        public async Task <int> GetTotalCount(string sWhere, Dapper.DynamicParameters param)
        {
            string sql = string.Format("select count(1) from Sys_AlarmLevel where 1=1 {0}", sWhere);

            return(await _context.QueryFirstOrDefaultAsync <int>(sql, param));
        }
 public async Task <Product> GetByIdAsync(int id)
 {
     return(await _context.QueryFirstOrDefaultAsync <Product>("SELECT * FROM Product WHERE Id=@Id", new { Id = id }));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 获取详情-sql通用查询
 /// </summary>
 /// <typeparam name="TEnity">根据sql定义Model</typeparam>
 /// <param name="sql"></param>
 /// <param name="param"></param>
 /// <param name="isCommandTypeText"></param>
 /// <param name="isInvoke">是否是委托方法里的执行sql</param>
 /// <returns></returns>
 public Task <TEnity> SQLQueryFirstOrDefaultAsync <TEnity>(string sql, object param = null, bool isCommandTypeText = true, bool isInvoke = false)
 {
     return(_context.QueryFirstOrDefaultAsync <TEnity>(sql, param, isCommandTypeText ? CommandType.Text : CommandType.StoredProcedure, isInvoke));
 }