protected void ButtonAddDatabase_Click(object sender, EventArgs e)
{
using (KnowItCvdbEntities db = new KnowItCvdbEntities())
{
SPWeb theSite = SPControl.GetContextWeb(Context);
SPUser theUser = theSite.CurrentUser;
string strUserName = theUser.LoginName;
var theEmplDbSkill = (
from p
in db.EMPLOYEES
where p.username == strUserName
select p).FirstOrDefault();
_emp = theEmplDbSkill;
if (_emp != null)
{
foreach (var vItem in ListBoxDatabases.Items)
{
if (ValueAlreadyInListDb(vItem))
return;
}
//Get existing skilllevel from db
var skillLevel = (from sL in db.TECHNICAL_SKILL_LEVEL
where sL.technical_skill_level_id == Convert.ToInt32(DropDownListDB.SelectedValue)
select sL).FirstOrDefault();
//Get existing skillvalue from db
var skillValue = (from sV in db.TECHNICAL_SKILLS
where sV.technical_skill_id == Convert.ToInt32(RadioButtonListDatabase.SelectedValue)
select sV).FirstOrDefault();
//Adding to employees_technical_skills table
var empSkill = new EMPLOYEES_TECHNICAL_SKILLS
{
technical_skill_id = Convert.ToInt32(DropDownListDB.SelectedItem.Value),
TECHNICAL_SKILLS = skillValue,
technical_skill_level_id = Convert.ToInt32(RadioButtonListDatabase.SelectedItem.Value)
TECHNICAL_SKILL_LEVEL = skillLevel,
employee_id = _emp.employee_id
}
_emp.EMPLOYEES_TECHNICAL_SKILLS_Add(empSkill);
db.SaveChanges();
_emp.EMPLOYEES_TECHNICAL_SKILLS.Add(empSkill);
db.SaveChanges();
}
}
}
现在我正在填充下表:
这是我的桌子:
但我不断收到错误:
LINQ to Entities 无法识别方法“Int32 ToInt32(System.String)”方法,并且该方法无法转换为存储表达式。
问候,克里斯蒂安。