コード例 #1
0
        private static void GetOrderItemComponents(ref OrderItem item)
        {
            SqliteConnection connection2 = new SqliteConnection();
            connection2.ConnectionString = "Data Source = " + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/" + fileName + ";Version=3;";

            connection2.Open();

            SqliteCommand command = new SqliteCommand();
            command.Connection = connection2;
            command.CommandType = CommandType.Text;
            command.CommandText = "select OrderItemComponents.Id, Components.Id, OrderItemComponents.VariationId, Components.Name, Components.DisplayName, OrderItemComponents.Portions, OrderItemComponents.Position from OrderItemComponents inner join Components on Components.Id = OrderItemComponents.ComponentId where OrderItemComponents.OrderItemId = " + item.Id.ToString();

            SqliteDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                int id = reader.GetInt32(0);
                int componentId = reader.GetInt32(1);
                int parentId = reader.GetInt32(2);
                string name = reader.GetString(3);
                string displayName = reader.GetString(4);
                int portions = reader.GetInt32(5);
                int position = reader.GetInt32(6);

                OrderItemComponent component = new OrderItemComponent(id, componentId, parentId, name, displayName, portions, position);

                GetOrderItemComponentComponents(ref component);

                item.AddComponent(component);
            }

            reader.Close();
            connection2.Close();
        }