コード例 #1
0
        public Order Find(string orderId)
        {
            using var db = new OrderContext();
            var entity = db.Find <OrderEntity>(orderId);

            return(new Order {
                Id = entity.id, State = (OrderStates)entity.state
            });
        }
コード例 #2
0
        public void Save(Order order)
        {
            using var db = new OrderContext();

            if (order.Id == null)
            {
                var orderEntity = CreateNewOrder(order, db);
                order.Id = orderEntity.id;
            }
            else
            {
                var fromDb = db.Find <OrderEntity>(order.Id);
                fromDb.state = (int)order.State;
            }

            db.SaveChanges();
        }