Example #1
0
        async Task Sorgula(CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                return;
            }
            TumStoklar.Clear();
            OnPropertyChanged(nameof(TumStoklar));
            gridView1.RefreshData();
            var pred = PredicateBuilder.True <Entities.Tables.Stok>();

            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.StokKodu.Contains(item) || x.Marka.Contains(item) || x.Uretici.Contains(item) || x.Barkod.Any(s => s.Barkodu.Contains(item)) || x.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);

                gridView1.RefreshData();
            }
        }