public TestData(string columnName, string searchString) { Queryable = new List<SomeModel>() { new SomeModel() { Category = 1, DisplayName = "Kapitein Archibald Haddock", Id = 123, Scale = 123.456d, Discounted = true, Cost = 123, When = new DateTime(2015,1,1,10,01,0) }, new SomeModel() { Category = 2, DisplayName = "Trifonius Zonnebloem", Id = 234, Scale = 234.567d, Discounted = true, Cost = 234, When = new DateTime(2016,1,1,10,01,0) } }.AsQueryable(); DataTablesRequest = new DataTablesRequest() { Length = 1, Draw = 1, Order = new List<DataTablesRequest.OrderT>() { new DataTablesRequest.OrderT() { Column = 2, Dir = "Asc" } }, Search = new DataTablesRequest.SearchT() }; Columns = ModelProperties<SomeModel>.Properties.Select(p => Tuple.Create(p.Name, new ModelProperty(p.PropertyInfo))).ToArray(); DataTablesRequest.Columns = Columns.Select(c => new DataTablesRequest.ColumnT() { Searchable = true, Orderable = true, Data = c.Item1, Search = new DataTablesRequest.SearchT() { Regex = false, Value = "" } }).ToArray(); var search = new DataTablesRequest.SearchT() { Value = searchString, Regex = false }; if (columnName.Any()) DataTablesRequest.Columns.Where(c => c.Data == columnName).First().Search = search; else DataTablesRequest.Search = search; }
public TestData(string columnName, string searchString) { Queryable = new List <SomeModel>() { new SomeModel() { Category = 1, DisplayName = "Kapitein Archibald Haddock", Id = 123, Scale = 123.456d, Discounted = true, Cost = 123, When = new DateTime(2015, 1, 1, 10, 01, 0) }, new SomeModel() { Category = 2, DisplayName = "Trifonius Zonnebloem", Id = 234, Scale = 234.567d, Discounted = true, Cost = 234, When = new DateTime(2016, 1, 1, 10, 01, 0) } }.AsQueryable(); DataTablesRequest = new DataTablesRequest() { Length = 1, Draw = 1, Order = new List <DataTablesRequest.OrderT>() { new DataTablesRequest.OrderT() { Column = 2, Dir = "Asc" } }, Search = new DataTablesRequest.SearchT() }; Columns = ModelProperties <SomeModel> .Properties.Select(p => Tuple.Create(p.Name, new ModelProperty(p.PropertyInfo))).ToArray(); DataTablesRequest.Columns = Columns.Select(c => new DataTablesRequest.ColumnT() { Searchable = true, Orderable = true, Data = c.Item1, Search = new DataTablesRequest.SearchT() { Regex = false, Value = "" } }).ToArray(); var search = new DataTablesRequest.SearchT() { Value = searchString, Regex = false }; if (columnName.Any()) { DataTablesRequest.Columns.Where(c => c.Data == columnName).First().Search = search; } else { DataTablesRequest.Search = search; } }