我有我想轉換爲實體框架翻譯INSERT INTO選擇實體框架
我需要在一個運行中插入多行中的實體像什麼這個查詢做
INSERT INTO dbo.tbllistDepartment
(
department_sys_id,
department,
status,
client_sys_id,
lang_sys_id
)
SELECT @siDepartmentSysId,@siDepartment, @iiStatus,
@siClientSysId, lang_sys_id
FROM tblLanguageSettings
WHERE lang_sys_id <> 'Admin001'
這個sql查詢
我已經試過,但其插入只有一行
public static void Insert(string langSysId, string clientSysId,string name, int status)
{
Crs2Model context = new Crs2Model();
string SysId = MyLibrary.StringCreator.GetSysId();
tblListDepartment deptObj = new tblListDepartment()
{
department_sys_id = SysId,
client_sys_id = clientSysId,
lang_sys_id=langSysId,
department=name,
status=status
};
context.tblListDepartments.Add(deptObj);
context.SaveChanges();
}
顯示您的DBContext名稱,我的朋友。 – Tomato32
我的問題已更新 –