Esempio n. 1
0
        async Task Sorgula(CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                return;
            }
            TumStoklar.Clear();

            OnPropertyChanged(nameof(TumStoklar));
            gridStoklar.RefreshData();
            var pred = PredicateBuilder.True <Entities.Tables.Stok>();

            if (!string.IsNullOrEmpty(txtStokKodu.Text))
            {
                pred = pred.And(x => x.StokKodu.Contains(txtStokKodu.Text));
            }
            if (!string.IsNullOrEmpty(txtStokAdi.Text))
            {
                pred = pred.And(x => x.StokAdi.Contains(txtStokAdi.Text));
            }
            if (!string.IsNullOrEmpty(txtAramaMetni.Text))
            {
                foreach (string item in txtAramaMetni.Text.Split(' '))
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        pred = pred.And(x => x.StokAdi.Contains(item) || x.Barkodu.Contains(item) || x.Marka.Contains(item) || x.Uretici.Contains(item) || x.StokKodu.Contains(item) || x.Barkod.Any(s => s.Barkodu.Contains(item)));
                    }
                }
            }

            var take  = 5000;
            var count = Math.Ceiling(
                Convert.ToDecimal(stokDal.StokKayitSayisi(context, pred) / Convert.ToDecimal(take)));

            if (token.IsCancellationRequested)
            {
                return;
            }
            for (int i = 0; i < count; i++)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }
                TumStoklar.AddRange(stokDal.StokAdiylaStokGetir(context, pred, take * i, take, noTracking: true));
                OnPropertyChanged(nameof(TumStoklar));
                await Task.Delay(100);

                gridStoklar.RefreshData();
                lblKayitSayisi.Text = TumStoklar.Count.ToString();
            }
        }