public async Task SelectAll() { IEnumerable <OverShortDetail> lst = null; using (var ctx = new OverShortDetailRepository()) { lst = await ctx.GetOverShortDetailsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false); } SelectedOverShortDetails = new ObservableCollection <OverShortDetail>(lst); }
// Send to Excel Implementation public async Task Send2Excel() { IEnumerable <OverShortDetail> lst = null; using (var ctx = new OverShortDetailRepository()) { lst = await ctx.GetOverShortDetailsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false); } if (lst == null || !lst.Any()) { MessageBox.Show("No Data to Send to Excel"); return; } var s = new ExportToExcel <OverShortDetailExcelLine, List <OverShortDetailExcelLine> > { dataToPrint = lst.Select(x => new OverShortDetailExcelLine { ReceivedQty = x.ReceivedQty, ItemNumber = x.ItemNumber, ItemDescription = x.ItemDescription, Cost = x.Cost, InvoiceQty = x.InvoiceQty, Status = x.Status }).ToList() }; using (var sta = new StaTaskScheduler(numberOfThreads: 1)) { await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false); } }