c# - Error in " SaveChanges() " method -
i'm creating application using oracle database , asp.net mvc4. though seems no problems in code, calling savechanges()
method causes error shown here:
this image shows inner exception , related details
this implementation have done saving changes
if (modelstate.isvalid) { modelstate.clear(); using (ssp_entities database = new ssp_entities()) { database.request_tab.add(c_modal.request_tab); database.savechanges(); caseid = c_modal.request_tab.case_id; return redirecttoaction("newenv", cpe); } }
i use following code in view
<%:html.hiddenfor(model => model.request_tab.rowversion, new { @value="date"}) %> <%:html.hiddenfor(model => model.request_tab.case_id, new { @value=100}) %> <%:html.hiddenfor(model => model.request_tab.request_by, new { @value="pusnlk"}) %> <%:html.hiddenfor(model => model.request_tab.request_id, new { @value=334}) %> <%:html.hiddenfor(model => model.request_tab.request_type, new { @value="cpe"}) %> <%:html.hiddenfor(model => model.request_tab.state, new { @value="posted"}) %> <%:html.hiddenfor(model => model.request_tab.comments, new { @value="cpe order"}) %>
this model i'm using
namespace cpeaspx.models { using system; using system.collections.generic; public partial class request_tab { public decimal request_id { get; set; } public string request_by { get; set; } public decimal case_id { get; set; } public string state { get; set; } public string request_type { get; set; } public string rowversion { get; set; } public string comments { get; set; } } }
i tried few solutions shown elsewhere. first changed <appsettings>
in web.config
file adding
<add key="aspnet:maxhttpcollectionkeys" value="5000" /> <add key="aspnet:maxjsondeserializermembers" value="5000" /> <add key="aspnet:maxhttpcollectionkeys" value="10000" />
lines it. problem continues. cannot find mismatch between client , server data types.
please me sort out problem.
here im passing 2 models single view. created following combined model that(c_model object of class)
using system; using system.collections.generic; using system.linq; using system.web; namespace cpeaspx.models { public class combinemodal { public request_tab request_tab = new request_tab(); public request_tab request_tab { { return request_tab; } set { request_tab = value; } } public cpe cpe = new cpe(); public cpe cpe { { return cpe; } set { cpe = value; } } } }
here says i'm passing cpe model i'm passing combined model contains cpe modal , request_tab modal in it.
this code use in view inherit modal class
<%@ page title="" language="c#" masterpagefile="~/views/shared/site.master" inherits="system.web.mvc.viewpage<cpeaspx.models.combinemodal>" %>
i think need assign each property instead of add whole class.
using (ssp_entities database = new ssp_entities()) { var requesttab = new requesttab { request_id = c_modal.request_tab.request_id, request_by = c_modal.request_tab.request_by, case_id = c_modal.request_tab.case_id, state = c_modal.request_tab.state, request_type = c_modal.request_tab.request_type, rowversion = c_modal.request_tab.rowversion, comments = c_modal.request_tab.comments }; database.request_tab.add(requesttab); database.savechanges(); }
Comments
Post a Comment