public virtual StringResource UpdateStringResource(StringResource entity) { if (entity.IsTransient()) { return(entity); } StringResource other = GetStringResource(entity.StringResourceId); if (entity.Equals(other)) { return(entity); } string sql = @"Update StringResource set [StringResourceGUID]=@StringResourceGUID , [StoreID]=@StoreID , [Name]=@Name , [LocaleSetting]=@LocaleSetting , [ConfigValue]=@ConfigValue , [Modified]=@Modified , [CreatedOn]=@CreatedOn where StringResourceID=@StringResourceID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@StringResourceID", entity.StringResourceId) , new SqlParameter("@StringResourceGUID", entity.StringResourceGuid) , new SqlParameter("@StoreID", entity.StoreId) , new SqlParameter("@Name", entity.Name) , new SqlParameter("@LocaleSetting", entity.LocaleSetting) , new SqlParameter("@ConfigValue", entity.ConfigValue ?? (object)DBNull.Value) , new SqlParameter("@Modified", entity.Modified) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetStringResource(entity.StringResourceId)); }
public virtual StringResource InsertStringResource(StringResource entity) { StringResource other = new StringResource(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into StringResource ( [StringResourceGUID] ,[StoreID] ,[Name] ,[LocaleSetting] ,[ConfigValue] ,[Modified] ,[CreatedOn] ) Values ( @StringResourceGUID , @StoreID , @Name , @LocaleSetting , @ConfigValue , @Modified , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@StringResourceID", entity.StringResourceId) , new SqlParameter("@StringResourceGUID", entity.StringResourceGuid) , new SqlParameter("@StoreID", entity.StoreId) , new SqlParameter("@Name", entity.Name) , new SqlParameter("@LocaleSetting", entity.LocaleSetting) , new SqlParameter("@ConfigValue", entity.ConfigValue ?? (object)DBNull.Value) , new SqlParameter("@Modified", entity.Modified) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetStringResource(Convert.ToInt32(identity))); } return(entity); }