asp.net mvc - Time out 500 error on Edmx -
i developed website using asp.net mvc , edmx database , published website on azure , database on azure , i've functionality on website uploads excel record database , excel sheet contain 18000 records every time upload sheet throw timeout error after time should do.
initially not using command timeout after doing research i'm using in constructor
public professionalservicesentities() : base("name=professionalservicesentities") { this.database.commandtimeout = 10000; //this.database.commandtimeout = 0; //i tried too. //((iobjectcontextadapter)this).objectcontext.commandtimeout = 3600; }
here code of function :-
public void saveequipments(ienumerable<equipsampleentity> collection) { using (professionalservicesentities db = new professionalservicesentities()) { string modelxml = xmlserialization.listtoxml(collection.where(x=>x.type == model).tolist()); string accessoryxml = xmlserialization.listtoxml(collection.where(x => x.type == accessory).tolist()); db.importequipmentfile(modelxml, accessoryxml); } }
here context file code sp:-
public virtual int importequipmentfile(string modelxml, string accessoryxml) { var modelxmlparameter = modelxml != null ? new objectparameter("modelxml", modelxml) : new objectparameter("modelxml", typeof(string)); var accessoryxmlparameter = accessoryxml != null ? new objectparameter("accessoryxml", accessoryxml) : new objectparameter("accessoryxml", typeof(string)); return ((iobjectcontextadapter)this).objectcontext.executefunction("importequipmentfile", modelxmlparameter, accessoryxmlparameter); }
you may processing excel on upload , processing row row. have 2 options, 1 schedule background job pickup upload file , insert db , complete request.
next option read whole file in 1 go , single bulk insert db.
Comments
Post a Comment