Ejemplo n.º 1
0
        /// <summary>
        /// 新增一筆資料並更新 Identity
        /// </summary>
        public virtual bool Insert(T model, IEnumerable <string> columns)
        {
            var    cmd      = SqlCommandHelper.GenerateInsert(model, columns);
            object identity = SqlHelper.ExecuteScalar(cmd);

            if (identity != null && identity != DBNull.Value)
            {
                var prop = CSharpHelper.GetIdentityProperty <T>();
                prop.SetValue(model, identity);
            }
            return(true);
        }