コード例 #1
0
        public static List <Stock> LoadStoks(IStatelessSession session, SimpleMRUCache cache,
                                             Settings settings, AddressStock AddressStock, Catalog Catalog)
        {
            if (AddressStock == null)
            {
                return(new List <Stock>());
            }
            var query = session.Query <Stock>()
                        .Fetch(x => x.Address)
                        .Where(x => x.Status == StockStatus.Available)
                        .Where(x => x.ProductId == Catalog.Id);

            return(query
                   .ToList());
        }
コード例 #2
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            RxQuery(s => {
                return(s.Query <Catalog>()
                       .Join(s.Query <Stock>(),
                             catalog => catalog.Id,
                             stock => stock.ProductId,
                             (catalog, stock) => new { catalog, stock })
                       .Where(p => p.stock.Status == StockStatus.Available)
                       .Select(c => c.catalog)
                       .OrderBy(c => c.Name)
                       .Distinct()
                       .ToArray()
                       .ToList());
            }).Subscribe(Catalogs);

            Catalogs
            .Changed()
            .Throttle(TimeSpan.FromMilliseconds(30), Scheduler)
            .Subscribe(_ =>
            {
                CurrentCatalog.Value = (Catalogs.Value ?? Enumerable.Empty <Catalog>()).FirstOrDefault();
            });

            CurrentCatalog
            .Changed()
            .Select(_ => RxQuery(LoadAddressStock))
            .Switch()
            .Subscribe(AddressStock, CloseCancellation.Token);

            AddressStock
            .Changed()
            .Throttle(TimeSpan.FromMilliseconds(30), Scheduler)
            .Subscribe(_ =>
            {
                CurrentAddressStock.Value = (AddressStock.Value ?? Enumerable.Empty <AddressStock>()).FirstOrDefault();
            });

            CurrentAddressStock
            .Changed()
            .Select(_ => RxQuery(LoadStoks))
            .Switch()
            .Subscribe(Stocks, CloseCancellation.Token);

            Stocks
            .Changed()
            .Throttle(TimeSpan.FromMilliseconds(30), Scheduler)
            .Subscribe(_ =>
            {
                CurrentStock.Value = (Stocks.Value ?? Enumerable.Empty <Stock>()).FirstOrDefault();
            });

            CurrentStock
            .Changed()
            .Select(_ => RxQuery(LoadStockActions))
            .Switch()
            .Subscribe(StockActions, CloseCancellation.Token);

            StockActions
            .Changed()
            .Throttle(TimeSpan.FromMilliseconds(30), Scheduler)
            .Subscribe(_ =>
            {
                CurrentStockAction.Value = (StockActions.Value ?? Enumerable.Empty <StockAction>()).FirstOrDefault();
            });
        }