コード例 #1
0
        public async Task <bool> UpdateOrderEnvent(IOrderEventEntity orderEvent)
        {
            using (var conn = new SqlConnection(_connectionString))
            {
                var sql = @"UPDATE [dbo].[Events]
   SET [ShipStatus] =@ShipStatus,[StorageStatus]=@StorageStatus    
 WHERE [OrderID]=@OrderID and EventType=@EventType";

                var result = await conn.ExecuteAsync(sql, param : new { orderEvent.OrderID, orderEvent.EventType, orderEvent.ShipStatus, orderEvent.StorageStatus }) > 0;

                return(result);
            }
        }
コード例 #2
0
        public async Task <bool> UpdateOrderEnvent(IOrderEventEntity orderEvent)
        {
            using (var conn = new SqlConnection(_connectionString))
            {
                var sql = $@"UPDATE [dbo].[Events]
   SET { (orderEvent.ShipStatus != 0 ? "[ShipStatus]=" + orderEvent.ShipStatus + "," : "")}{(orderEvent.StorageStatus != 0 ? "[StorageStatus]=" + orderEvent.StorageStatus + "," : "")  }";

                sql = sql.TrimEnd(',') + " WHERE [OrderID]=@OrderID and EventType=@EventType";

                Console.WriteLine("----------------------------");
                Console.WriteLine(sql.Replace("@OrderID", $"'{orderEvent.OrderID}'").Replace("@EventType", $"'{orderEvent.EventType}'"));
                Console.WriteLine("----------------------------");
                var result = await conn.ExecuteAsync(sql, param : new { orderEvent.OrderID, orderEvent.EventType }) > 0;

                return(result);
            }
        }