public override int[] ExecuteParams(DataTablesParam dataTablesParam) { DataContext.Dispose(); //reset datacontext in order to clear local DataContext = new SomeContext(); int[] returnVar = base.ExecuteParams(dataTablesParam); Assert.AreEqual(returnVar.Length, DataContext.Models.Local.Count, "records loaded in memory"); return returnVar; }
public virtual int[] ExecuteParamsAndTransform(DataTablesParam dataTablesParam) { var result = DataTablesResult.Create(SomeModelQueryable, dataTablesParam, m => new { FriendlyWhen = m.When.ToShortDateString(), }); var data = result.Data; return data.aaData.Select(d=>Convert.ToInt32(((IList)d)[0])).ToArray(); }
public void Setup() { queryable = new List<SomeModel>() { new SomeModel() { Category = 1, DisplayName = "Cheddar", Id = 123, Scale = 123.456d, Discounted = true, Cost = 123 } }.AsQueryable(); dataTablesParam = new DataTablesParam(); columns = DataTablesTypeInfo<SomeModel>.Properties.Select((p, i) => Tuple.Create(i, new DataTablesPropertyInfo(p.PropertyInfo, new DataTablesAttributeBase[]{}))).ToArray(); dataTablesParam.sSearchColumns = new List<string>(columns.Select(c => null as string)); dataTablesParam.bSearchable = new List<bool>(columns.Select(c => true)); }
static DataTablesParam GetEmptyParam(int columns) { var returnVar = new DataTablesParam(columns); returnVar.iDisplayLength = DefaultTestCasesLength; returnVar.iSortingCols = 1; returnVar.sEcho = 1; returnVar.sSearch = ""; returnVar.bEscapeRegexColumns.AddRange(Enumerable.Repeat(false, columns)); returnVar.bSearchable.AddRange(Enumerable.Repeat(true, columns)); returnVar.bSortable.AddRange(Enumerable.Repeat(true, columns)); returnVar.iSortCol.AddRange(Enumerable.Repeat(0, columns)); returnVar.sSearchColumns.AddRange(Enumerable.Repeat("", columns)); returnVar.sSortDir.AddRange(Enumerable.Repeat<string>(null, columns)); return returnVar; }
public virtual int[] ExecuteParams(DataTablesParam dataTablesParam) { var result = new DataTablesResult<SomeModel>(SomeModelQueryable, dataTablesParam); var data = result.Data; return data.aaData.Select(row => ((SomeModel)row).Id).ToArray(); }