最近,我在我的 UserMap 类中添加了一个新列,以添加一个 int 数组
public class UserMap : ClassMap<User>
{
public UserMap()
{
Table("user");
LazyLoad();
Id(x => x.Id).GeneratedBy.Identity().Column("Id");
Map(x => x.DateCreated).Column("DateCreated").Not.Nullable();
Map(x => x.Birthday).Column("Birthday").Nullable();
Map(x => x.HideBirthday).Column("HideBirthday").Nullable();
Map(x => x.Name).Column("Name").Not.Nullable();
Map(x => x.Email).Column("Email").Not.Nullable();
Map(x => x.PassWord).Column("Password").Not.Nullable();
Map(x => x.NotificationCounter).Column("NotificationCounter").Nullable().Default("0");
//EMAILPRIVACY = int[]
Map(x => x.EmailPrivacy).Column("EmailPrivacy").Nullable();
}
}
因此,我需要使用 int 数组向EmailPrivacy列添加默认值。
new int[] { 1, 2, 3, 4, 5, 6, 7 }
当我添加默认值时,出现错误:
Map(x => x.EmailPrivacy).Column("EmailPrivacy").Nullable().Default(new int[] { 1, 2, 3, 4, 5, 6, 7 }.ToString());
错误信息:
Unknown column 'user0_.EmailPrivacy' in 'field list'
[MySqlException (0x80004005): Unknown column 'user0_.EmailPrivacy' in 'field list']
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +383
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId) +116
MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId) +54
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +142
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +1249
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +2214
MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +12
NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +347
NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) +364
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +425
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +213
NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, String optionalEntityName, Object optionalIdentifier, IEntityPersister persister) +386
如何添加此 int[] 默认值?
提前谢谢大家