在 Informix 数据库和 FluentNhibernate 中保存 Smart Blob
Save Smart Blob in Informix Database and FluentNhibernate
我需要在 informix 数据库中保存一个 Smart Blob,这是我的模型:
public class ArtistaFoto : Entity
{
public virtual Artista Artista { get; set; }
public virtual int NumeroSeq { get; set; }
public virtual byte[] BlobArtistas { get; set; }
public virtual string NomeArquivos { get; set; }
public virtual string Extensao { get; set; }
}
有我的映射
public ArtistaFotosMapping()
{
this.Table("sb_aneartistas");
this.CompositeId().KeyReference(x => x.Artista, "cdartista").KeyProperty(x => x.NumeroSeq, "nrseq");
this.Map(x => x.BlobArtistas).Column("sbaneartistas");
this.Map(x => x.NomeArquivos).Column("nome_arq");
this.Map(x => x.Extensao).Column("extensao");
}
当我尝试保存我的实体时出现异常
所以我知道 Informix 数据库中的这个字段是一个 SmartBlob,这不是一个普通的 blob(字节或字符串)。有人可以帮助我吗?
我的难点在于建立连接:
ISessionFactory factory = Fluently.Configure()
.Database(
IfxSQLIConfiguration
.Informix1000
.ConnectionString("Provider=Ifxoledbc.2;Password=xxxx;Persist Security Info=True;User ID=xxxx;Data Source=xxxx")
.Driver<OleDbDriver>()
.Dialect<InformixDialect1000>()
.ShowSql())
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<ArtistaFotoMapping>()
).ExposeConfiguration(x =>
x.SetProperty(NHibernate.Cfg.Environment.PrepareSql, "True")
)
.BuildSessionFactory();`
我更改了 IfxOdbcConfiguration 示例:
ISessionFactory factory = Fluently.Configure()
.Database(
IfxOdbcConfiguration
.Informix1000
.ConnectionString("DRIVER={IBM INFORMIX ODBC DRIVER};SERVER=xxxx;DATABASE=xxxx;UID=xxx;PWD=xxx;NEEDODBCTYPESONLY=1;")
.ShowSql())
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<ArtistaFotoMapping>()
).ExposeConfiguration(x =>
x.SetProperty(NHibernate.Cfg.Environment.PrepareSql, "False")
)
.BuildSessionFactory();
我需要在 informix 数据库中保存一个 Smart Blob,这是我的模型:
public class ArtistaFoto : Entity
{
public virtual Artista Artista { get; set; }
public virtual int NumeroSeq { get; set; }
public virtual byte[] BlobArtistas { get; set; }
public virtual string NomeArquivos { get; set; }
public virtual string Extensao { get; set; }
}
有我的映射
public ArtistaFotosMapping()
{
this.Table("sb_aneartistas");
this.CompositeId().KeyReference(x => x.Artista, "cdartista").KeyProperty(x => x.NumeroSeq, "nrseq");
this.Map(x => x.BlobArtistas).Column("sbaneartistas");
this.Map(x => x.NomeArquivos).Column("nome_arq");
this.Map(x => x.Extensao).Column("extensao");
}
当我尝试保存我的实体时出现异常
所以我知道 Informix 数据库中的这个字段是一个 SmartBlob,这不是一个普通的 blob(字节或字符串)。有人可以帮助我吗?
我的难点在于建立连接:
ISessionFactory factory = Fluently.Configure()
.Database(
IfxSQLIConfiguration
.Informix1000
.ConnectionString("Provider=Ifxoledbc.2;Password=xxxx;Persist Security Info=True;User ID=xxxx;Data Source=xxxx")
.Driver<OleDbDriver>()
.Dialect<InformixDialect1000>()
.ShowSql())
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<ArtistaFotoMapping>()
).ExposeConfiguration(x =>
x.SetProperty(NHibernate.Cfg.Environment.PrepareSql, "True")
)
.BuildSessionFactory();`
我更改了 IfxOdbcConfiguration 示例:
ISessionFactory factory = Fluently.Configure()
.Database(
IfxOdbcConfiguration
.Informix1000
.ConnectionString("DRIVER={IBM INFORMIX ODBC DRIVER};SERVER=xxxx;DATABASE=xxxx;UID=xxx;PWD=xxx;NEEDODBCTYPESONLY=1;")
.ShowSql())
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<ArtistaFotoMapping>()
).ExposeConfiguration(x =>
x.SetProperty(NHibernate.Cfg.Environment.PrepareSql, "False")
)
.BuildSessionFactory();