GridModel[] Read(DextopReadFilter filter) { return new[] { new GridModel { Id = 1, Name = "Bill", Age = 30, Height=180 }, new GridModel { Id = 2, Name = "Bob", Age = 26, Height=175 } }; }
IEnumerable<ComboModel> GetValues3(DextopReadFilter filter) { var baseValue = filter.Params.SafeGet("Value2", 0); for (var i = baseValue+1; i < 10; i++) yield return new ComboModel { Id = i }; }
/// <summary> /// Creates the paged result by reading the IQueryable source. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source">The source.</param> /// <param name="filter">The filter.</param> /// <param name="fastTotal">Indicates that N+1 paging is used.</param> /// <returns></returns> public static DextopReadResult <T> CreatePage <T>(IQueryable <T> source, DextopReadFilter filter, bool fastTotal = false) where T : class { if (filter == null) { throw new ArgumentNullException("filter"); } source = ApplySort(source, filter); if (filter.limit.HasValue) { int limit = filter.GetLimit(); int start = filter.GetStart(); if (fastTotal) { var data = source.Skip(start).Take(limit + 1).ToArray(); return(Create(data.Take(limit).ToArray(), start + data.Length)); } else { return(Create(source.Skip(start).Take(limit).ToArray(), source.Count())); } } return(Create(source.ToArray())); }
/// <summary> /// /// </summary> /// <param name="filter"></param> /// <returns></returns> public DextopReadResult <T> Read(DextopReadFilter filter) { if (Paging) { return(DextopReadResult.CreatePage(data.Values.AsQueryable(), filter)); } return(DextopReadResult.Sort(data.Values.AsQueryable(), filter)); }
/// <summary> /// Creates the result by sorting end enumerating the specified source. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source">The source.</param> /// <param name="filter">The filter.</param> /// <returns></returns> public static DextopReadResult <T> Sort <T>(IQueryable <T> source, DextopReadFilter filter) where T : class { if (filter == null) { throw new ArgumentNullException("filter"); } source = ApplySort(source, filter); return(Create(source.ToArray())); }
CurrencyHistoryRate[] LoadHistory(DextopReadFilter filter) { String iso; filter.Params.TryGet<String>("ISOCode", out iso); var baseCurency = filter.Params.SafeGet<String>("BaseCurrencyISOCode", "EUR"); if (baseCurency == "EUR") return CurrencyHistoryDataProvider.GetCurrencyRateHistory(iso); else return CurrencyHistoryDataProvider.GetCurrencyRateComparisionHistory(iso, baseCurency); }
RateModel[] Load(DextopReadFilter filter) { var currency = filter.Params.SafeGet("Currency", "EUR"); var amount = filter.Params.SafeGet("Amount", 100.0m); var data = CurrencyDataProvider.GetCurrencyList(currency); return data.Rates.Select(a => new RateModel { Currency = a.Currency, ISOCode = a.ISOCode, Rate = a.Rate, Amount = amount * a.Rate }).ToArray(); }
RemoteLookupModel[] RemoteLookup(DextopReadFilter filter) { String query = filter.Params.SafeGet<String>("query"); var data = new [] { new RemoteLookupModel { Code = "Red", Description = "Code Red"}, new RemoteLookupModel { Code = "Blue", Description = "Code Blue"}, new RemoteLookupModel { Code = "Green", Description = "Code Green"}, }; if (String.IsNullOrWhiteSpace(query)) return data; return data.Where(a => a.Code.StartsWith(query) || a.Description.Contains(query)).ToArray(); }
static IQueryable <T> ApplySort <T>(IQueryable <T> source, DextopReadFilter filter) where T : class { if (filter == null) { return(source); } if (filter.sort != null && filter.sort.Length > 0) { var sorter = filter.sort[0]; bool asc = IsAscendingDirection(sorter.direction); source = source.OrderBy(sorter.property, asc); for (var i = 1; i < filter.sort.Length; i++) { sorter = filter.sort[i]; asc = IsAscendingDirection(sorter.direction); source = source.ThenBy(sorter.property, asc); } } return(source); }
DextopReadResult IDextopReadProxy.Read(DextopReadFilter options) { return(proxy.Read(options)); }
/// <summary> /// Reads the data using specified filter. /// </summary> /// <param name="filter">The filter.</param> /// <returns></returns> public DextopReadResult <T> Read(DextopReadFilter filter) { return(d(filter)); }
Stock[] Load(DextopReadFilter filter) { var data = StockDataProvider.GetStockData(); return data.ToArray(); }
GridModel[] Read(DextopReadFilter filter) { return new[] { new GridModel { Id = 1, Date = DateTime.Today, Bool = true, Time = DateTime.Now.TimeOfDay, Tooltip = "Hover", TooltipField = "Leave me alone!"} }; }
DextopReadResult IDextopReadProxy.Read(DextopReadFilter filter) { return(proxy.Read(filter)); }
/// <summary> /// Read records using the specified filter. /// </summary> /// <param name="filter">The filter.</param> /// <returns>Read result.</returns> public abstract DextopReadResult <T> Read(DextopReadFilter filter);
DextopReadResult<GridModel> Read(DextopReadFilter filter) { return DextopReadResult.CreatePage(data.AsQueryable(), filter); }