sqlsugar 无实体表达式更新多个字段

private void btnSave_Click(object sender, EventArgs e)
{
	FileStream fs = File.OpenRead(txtFileName.Text);
	byte[] imageb = new byte[fs.Length];
	fs.Read(imageb, 0, imageb.Length);
	fs.Close();
	string ls_emp_code = txtEmpCode.Text.Trim();
	string ls_filepath = txtFileName.Text.Trim();
        //更新一个字段
	//var result = SqlSugarHelper.SqlSugarClient.Updateable<t_emp_fp>().SetColumns("face_pic", imageb).Where("emp_code='" + ls_emp_code + "'").ExecuteCommand();
        //更新多个字段
	var result = SqlSugarHelper.SqlSugarClient.Updateable<t_emp_fp>().SetColumns(p=>new t_emp_fp { face_pic = imageb, filepath = ls_filepath }).Where("emp_code='" + ls_emp_code + "'").ExecuteCommand();
	if (result <= 0)
	{
		MessageBox.Show("更新相片到數據庫有問題", "提示");
		return;
	}

posted on 2022-08-04 21:27  manber  阅读(821)  评论(0编辑  收藏  举报

导航