My EF Core BulkInsert throws error when inserting more than 80 rows, below is the example insert 80 rows data
Insert 80 rows
but when i try 100rows the error as shown
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Im using JSON for the data
function Save() {
var fail = {
title: 'Data insert fail',
message: 'refresh page to save again',
position: 'topRight'
};
console.log(_oSeismics);
if (_oSeismics.length > 0) {
var ajaxRequest = $.ajax({
url: "../PmepTempAdd/SavePmepVSP/",
type: "POST",
data: { data: _oSeismics },
dataType: "json",
beforeSend: function () {
},
});
ajaxRequest.done(function (data) {
swal('Success!', 'Successfully saved.', 'success');
});
ajaxRequest.fail(function (jqXHR, textStatus) {
iziToast.error(
fail
);
});
}
else {
iziToast.error(
fail
);
}
}
function NewSeismicObj() {
var now = new Date();
var date = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
var time = now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
var dateTime = date + ' ' + time;
console.log(dateTime)
var oSeismic = {
No: "",
WellName: "",
SurveyVspYaTdk: "",
VspSonicCalibrationSynthetic: "",
VspReport: "",
VelocityWellCheckshot: "",
WellProgramProposal: "",
FinalWellReportEndOfWellReport: "",
ProcessingDataSgy: "",
RawDataSgy: "",
Recommendation: "",
RowCreated: dateTime
};console.log(dateTime)
return oSeismic;
}
Any Idea whats wrong with this code? for 80 rows runs normal, but over 80 error shown as above
Edit :
I have tried to change parameter into data but still error
PmepTempAddController.cs code
public JsonResult SavePmepVSP(List<VerTempPmepSeismicVsp> data)
{
_VSPt = _db.SavePmepSeismicsVSP(data);
TempData["success"] = "Inserted to TempPmeporary Table successfully";
return Json(_VSP);
}
Service.cs code
public List<VerTempPmepSeismicVsp> SavePmepSeismicsVSP(List<VerTempPmepSeismicVsp> data)
{
_dbContext.BulkInsert(data);
return data;
}
Sometimes Its also depends on which parameter are you using...
var ajaxRequest = $.ajax({
url: "../PmepTempAdd/SavePmepVSP/",
type: "POST",
data: { data: _oSeismics },
dataType: "json",
beforeSend: function () {
},
});
here you have written data: { data: _oSeismics }, So, in the backend, it must have something like the below...
public List<VerTempPmepSeismicVsp> SavePmepVSP( List<VerTempPmepSeismicVsp> data)
Note: Look at the name of parameter.