This is my code for creating Json response for jqGrid and for new keyword for defining cell member I receive following message "No best type found for implicitly-typed array".
var resRows = results.Select(record =>
new
{
id = record.Reference,
cell = **new** []
{
record.Reference,
record.TradeDate.ToShortDateString(),
record.Currency1,
record.Currency2,
record.Notional.ToString(),
record.EffectiveDate.ToShortDateString(),
record.Quote.ToString()
}
}).ToArray();
What am I doing wrong here?
Assuming Reference
, Currency1
and Currency2
are strings, just declare it as a string array:
var resRows = results.Select(record =>
new
{
id = record.Reference,
cell = new string []
{
record.Reference,
record.TradeDate.ToShortDateString(),
record.Currency1,
record.Currency2,
record.Notional.ToString(),
record.EffectiveDate.ToShortDateString(),
record.Quote.ToString()
}
}).ToArray();
If you prepare data for jqGrid (like in your code), you can define your own jsonReader and just skip the cell array (http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data):
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
userdata: "userdata"
},
Then something like:
var result = new
{
total = (int)count / grid.PageSize),
page = grid.PageIndex,
records = count,
rows = results.Select(record =>
select new
{
Reference = record.Reference,
TradeDate = record.TradeDate,
..
}).ToArray()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With