我有这样的服务方法:
[OperationContract]
public void CreateIcd9(int icd9ID, string code, string description, string specialty)
{
var count = from icd in clogicEntities.ICD9
where icd.ID == icd9ID
select icd;
if (count.Count() >= 1)
{
var icd9 = clogicEntities.ICD9.Where(icd => (icd.ID == icd9ID)).SingleOrDefault();
if (icd9 != null)
{
icd9.CODE = code;
icd9.DESCRIPTION = description;
icd9.SPECIALTY = specialty;
}
}
else
{
ICD9 icdNew = new ICD9()
{
ID = icd9ID,
CODE = code,
DESCRIPTION = description,
SPECIALTY = specialty
};
// Insert Icd9
clogicEntities.ICD9.AddObject(icdNew);
}
clogicEntities.SaveChanges();
}
直到今天一切都很好,当我调用这个方法时我得到了一个异常,icd9ID = 1992401733
我得到了这个异常:
An error occurred while updating the entries.
See the inner exception for details. ----> System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'ID', table '1224-CLOGIC.dbo.ICD9'; column does not allow nulls. INSERT fails.
The statement has been terminated
我尝试重现此问题但没有运气,我想知道这是 MAX Int 问题:2147483647 - MAX Int 1992401733 - 我的价值请帮助我。