Programing Language/.Net Core
C#) get property 값으로 update 쿼리문 만들기
Jude_Song
2022. 12. 13. 17:03
728x90
반응형
var sql = $"update project_information set ";
var getObject = get;
PropertyInfo[] properties = getObject.GetType().GetProperties();
foreach (var props in properties)
{
var key = props.Name;
var myVal = props.GetValue(getObject);
if ($"{myVal}" != "" && myVal != null)
{
if (key != "no" && key != "user_id" && key != "ref_video_url")
{
sql += $"{props.Name} = \'{myVal}\', ";
}
}
}
sql += $"updated_at = \'{PublicMethod.nowTime()}\', ";
sql = sql.Remove(sql.Length - 2);
sql += $" where id = \'{get.user_id}\' AND no = \'{get.no}\'";
도움되셨다면 광고 클릭 센스!!
728x90
반응형