次のようなサービスメソッドがあります。
[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 - 私の値 助けてください。