我是实体框架的新手,在尝试将新项目插入查找表时遇到了问题。
错误是 -
System.StackOverflowException
“ mscorlib.dll中出现未处理的类型异常”
它被抛出到下面DIEMEntities()
调用 public 的最终代码块中。
每当我添加新项目时都会发生这种情况,我可以更新项目。
任何帮助,将不胜感激。
代码是 -
protected void OnSave(object sender, EventArgs e)
{
ArrayList validationErrors = new ArrayList();
ContactTypeEO contactType = new ContactTypeEO();
if (uxID.Value.Length > 0)
{
//Updating
contactType.Id = int.Parse(uxID.Value);
}
contactType.Name = uxName.Text;
contactType.ExpressionValidator = uxExpression.Text;
contactType.Save(ref validationErrors);
if (validationErrors.Count > 0)
{
ShowValidationMessages(validationErrors);
}
else
{
this.RefreshUI();
}
}
public bool Save(ref ArrayList validationErrors)
{
ValidateSave(ref validationErrors);
if (validationErrors.Count == 0)
{
if (Id == 0)
{
ContactTypeData.Insert(Name, ExpressionValidator);
}
else
{
ContactTypeData.Update(Id, Name, ExpressionValidator);
}
return true;
}
else
{
return false;
}
}
/// <summary>
/// Inserts the new Contact Type.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="validator">The validator.</param>
public static void Insert(string name, string validator)
{
using (DIEMEntities diemEntities = new DIEMEntities())
{
Insert(name, validator);
}
}
/// <summary>
/// Inserts the new Contact Type.
/// </summary>
/// <param name="diemEntities">The DIEM Entities.</param>
/// <param name="name">The name.</param>
/// <param name="validator">The validator.</param>
public static void Insert(DIEMEntities diemEntities, string name, string validator)
{
diemEntities.usp_ContactTypes_Insert(name, validator);
}
public partial class DIEMEntities : DbContext
{
public DIEMEntities()
: base("name=DIEMEntities")
{
}
... OTHER CODE}