次のアクションメソッドがあります。
[Authorize]
public ActionResult CustomersDetails(long[] SelectRight)
{
if (SelectRight == null)
{
return RedirectToAction("customer", new { isError = true });
}
else
{
try
{
var ContactsDetails2 = new ContactsDetails
{
Info = r.getcontactinfo(SelectRight)
};
foreach (var x in ContactsDetails2.Info)
{
ViewData[x.USER_ID.ToString()] = r.getorgname(x.USER_ID).ToString();
}
return View(ContactsDetails2);
}
catch (SqlException)
{
ModelState.AddModelError("", "Too many records will be returned, please try to minimize your selection and try again.");
return RedirectToAction("customer", "Home");
}
}
}
そして次の方法:
public IEnumerable<AaaUserContactInfo> getcontactinfo(long[] id)
{
var organizationsiteids = from accountsitemapping in entities.AccountSiteMappings
where id.Any(accountid => accountsitemapping.ACCOUNTID == accountid)
select accountsitemapping.SITEID;
//code goes here
getcontactinfo で次の例外が発生した場合:-
[SqlException (0x80131904): SQL ステートメントの一部のネストが深すぎます。クエリを書き直すか、より小さなクエリに分割してください。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +388
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock , Boolean asyncClose) +688
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +82
システム.Data.SqlClient.SqlDataReader.get_MetaData() +135
.... **catch (SqlException)**
届かない?