Trong ứng dụng asp.net MVC của tôi, tôi nhận được một lỗi trong chỉnh sửa chức năng: trong mã choĐã xảy ra lỗi khi thực hiện định nghĩa lệnh. Xem các ngoại lệ bên trong để biết chi tiết
public ActionResult Edit(int id)
{
var res = (from r in objeEntities.DocumentationsSet.Include("DocStatus")
where r.textid == id select r)
.First();
}
Tôi nhận được ngoại lệ này:
Source : System.Data.Entity
Stack Trace :
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext
context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at System.Data.Objects.ELinq.ObjectQueryProvider.b__0[TResult](IEnumerable`1 sequence)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.First[TSource](IQueryable`1 source)
at admin.com.Controllers.DocsGridController.Edit(Int32 id) in c:\Data\FinalCode\AC015\acomMVCSourceCode\admincom\Controllers\DocsController.cs:line
307
Message : An error occurred while executing the command definition. See the inner exception for details.
Lỗi này được tạo khi tôi kết nối với máy chủ từ xa.
Lỗi này là gì? Làm thế nào để tôi sửa chữa nó?
"Xem ngoại lệ bên trong để biết chi tiết". Bạn đã hoàn thành chưa? Nó nói gì? –
Điều này có lẽ là hiển nhiên, nhưng cách để truy cập ngoại lệ bên trong là từ đối tượng ngoại lệ. Vì tôi đã có một khối thử trong một khối thử, tôi lầm tưởng rằng nó đang ám chỉ đến bên trong ... ừm, điều đó gây nhầm lẫn cho tôi. – micahhoover
Ngoại lệ bên trong cho tôi chỉ ra một ánh xạ không thành công đối với một số bảng mới mà tôi thậm chí không muốn. Tôi đã tạo lại mô hình của mình và chọn các bảng cụ thể mà tôi muốn và sự cố đã biến mất. – micahhoover