Я разрабатываю это в ASP.NET MVC2
Получение исключения:
Object reference not set to an instance of an object
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="Anonymously Hosted DynamicMethods Assembly"
StackTrace:
at lambda_method(ExecutionScope , TrusteeMaster )
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at LexEyeSystem.Controllers.TrusteeMasterController.JsonContractCollection(Int32 page, Int32 rows, String sidx, String sord) in D:\ParallelMinds\Projects\LexEye\Controllers\TrusteeMasterController.cs:line 560
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException:
Я пытаюсь показать jqgrid, для этого мне нужно написать это возвращающее JSON действие, котороесодержит мой этот запрос Linq.Тот же запрос выполняется правильно на других страницах:
var jsonData = new
{
total = totalPages,
page = page,
records = totalRecords,
rows = (
from s in sortedList
select new
{
cell = new string[] {
"TrustContract/Edit/"+ s.TrusteeId.ToString(),
s.FullName,
s.OtherName.ToString(),
s.FatherName,
s.TrusteeGender,
s.ResidentialAddress,
s.CommunicationAddress,
s.Occupation,
s.Nationality,
s.DateOfBirth.Value.ToShortDateString(),
s.PlaceOfBirth,
s.TelephoneNumber,
s.FacsimileNumber,
s.MobileNumbers,
s.EmailId,
s.ElectionIdCardNumber,
s.PANCardNumber,
s.TaxRegistrationNumber,
s.Qualification,
s.ExperienceInYears.ToString(),
s.Resume.ToString(),
"DisclousureInterestDetails/Index/"+ s.TrusteeId.ToString(),//+"?trusteeId="+s.TrusteeId.ToString(),
"ForeignDetail/Create/"+ s.TrusteeId.ToString(),
"InterestedOtherCompanyInformation/Index/"+ s.TrusteeId.ToString(),
"RelativesDetails/Index/"+ s.TrusteeId.ToString()
}
}).ToArray()
};
Но почему он не должен выполняться здесь?
Редактировать: Запрос LINQ для получения sortedList:
var sortedList = objTrusteeMasterList
.AsQueryable()
.OrderBy(orderBy) // Uses System.Linq.Dynamic library for sorting
.Skip(pageIndex * pageSize)
.Take(pageSize);