public List <OrderDetailsExtended> GetCustOrdersDetail(Int32 id)
        {
            List <OrderDetailsExtended> details = new List <OrderDetailsExtended>();

            using (var connection = providerFactory.CreateConnection())
            {
                connection.ConnectionString = connectionString;
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "CustOrdersDetail";

                    var paramId = command.CreateParameter();
                    paramId.ParameterName = "@OrderID";
                    paramId.Value         = id;
                    command.Parameters.Add(paramId);

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var det = new OrderDetailsExtended();
                            det.Product       = reader.GetValue(0) as String;
                            det.UnitPrice     = (Decimal)reader.GetValue(1);
                            det.Quantity      = (Int16)reader.GetValue(2);
                            det.Discount      = (Int32)reader.GetValue(3);
                            det.ExtendedPrice = (Decimal)reader.GetValue(4);
                            details.Add(det);
                            //{
                            //    Product = reader.GetValue(0) as String, UnitPrice = (Decimal)reader.GetValue(1),
                            //    Quantity = (Int32)reader.GetValue(2), Discount = (Int32)reader.GetValue(3),
                            //    ExtendedPrice = (Decimal)reader.GetValue(4)
                            //});
                        }
                    }
                }
            }

            return(details);
        }
Пример #2
0
        public void TestFindReadOnlyEntity()
        {
            OrderDetailsExtended orderDetail = gateway.Find <OrderDetailsExtended>(10248);

            Assert.IsNotNull(orderDetail);
        }