示例#1
0
        public IEnumerable<Order> FindBy(Infrastructure.Query query)
        {
            IList<Order> orders = new List<Order>();

            using (SqlConnection conn = new SqlConnection(_connectionString)) 
            {
                SqlCommand cmd = conn.CreateCommand();
                query.TranslateInfo(cmd);
                conn.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read()) 
                    {
                        orders.Add(new Order() 
                        {
                            CustomerId = new Guid(reader["CustomerId"].ToString()),
                            OrderDate = DateTime.Parse(reader["OrderDate"].ToString()),
                            Id = new Guid(reader["Id"].ToString()),
                        });
                    }
                }
            }

            return orders;
        }