我正在发送这样的 Json 数据
var books = bookInfoService.GetAllBookInfo(1);
var bookList = from w in books
from x in w.BookAuthors
select new
{
authorName = x.Authors.Name
};
var bookShelfs = bookShelfService.GetAllBookShelfs(1);
var jsonData = from w in bookShelfs select new { w.Id, w.Price, w.BarcodeId, w.BookInfos_s.Title, w.BookInfos_s.BookCategories.CategoryName,bookList};
return Json(jsonData, JsonRequestBehavior.AllowGet);
在 Jqgrid 中,我有一列显示 authorName 的值。该列的代码如下所示。
{ name: 'authorName', width: 180, align: 'center', editable: false },
和我的萤火虫显示数据,如
[{"Id":1,"Price":23,"BarcodeId":1000,"Title":"HeadFirst C#","CategoryName":"Book","bookList":[{"autorId":1," authorName":"Skiena"}]}
我想在 authorName 列中获取作者姓名。但是我该怎么做呢?是否可以在 jsonData 中传递作者姓名?喜欢
var jsonData = from w in bookShelfs select new { w.Id, w.Price, w.BarcodeId, w.BookInfos_s.Title, w.BookInfos_s.BookCategories.CategoryName} from s in books select new{s.Authors.Name};