fluent-nhibernate

Storing an object[] as column in Fluent NHibernate

孤街醉人 提交于 2019-12-12 01:07:59
问题 I have the following (partial) model: class LogMessage{ string Format; object[] args; } I want to store args[] as a single column in the table, taking advance of the fact that format arguments are generally serializable or can be converted to a string a priori . I don't want to store the formatted message, I want to separately store format and args (this has several advantages). How can I tell Fluent NHibernate to use a BLOB type to store that column and perform simple binary serialization

Is it possible to map a composite key in fluent nhibernate where half of the key is an identity field in the database?

醉酒当歌 提交于 2019-12-11 23:12:00
问题 As the question states, is it possible to map a composite key in fluent nhibernate (or non fluent i suppose) where one of the two fields used in the composite is an identity field? I have a table where one part of the primary key is an identity field and the other is a tenant id. This is a legacy database where the composite key is used as foreign keys all over, so modifying the database would be quite significant. thanks! 回答1: If it's really an identity column, then it's guaranteed to be

Map to Serializable in Fluent NHibernate

佐手、 提交于 2019-12-11 20:36:24
问题 NHibernate has a "Serializable" type <property name="PropertyName" column="ColumnName" type="**Serializable**" /> Is there a built in type for this in Fluent NHibernate? Something like Map(x => x.PropertyName).CustomType<**SerializableType**>(); ?? 回答1: Map(c => c.PropertyName).CustomType<NHibernate.Type.SerializableType>() seems to do it 回答2: Map(c => c.PropertyName).CustomType("serializable"); 来源: https://stackoverflow.com/questions/2000798/map-to-serializable-in-fluent-nhibernate

How to pass DataTable as a parameter to Stored Procedure by not commiting the current session transaction?

≡放荡痞女 提交于 2019-12-11 19:55:12
问题 My code looks like this: public void InsertSampleData(DataTable tempTable) { session.Transaction.Commit(); var connection = session.GetSessionImplementation().Connection; using (var sqlConnection = (SqlConnection)connection) { using (var cmd = sqlConnection.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "dbo.insertData"; cmd.Parameters.Add("@sItems", SqlDbType.Structured); var sqlParam = cmd.Parameters["@Items"]; sqlParam.Direction = ParameterDirection

Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000

橙三吉。 提交于 2019-12-11 18:56:38
问题 I have a tests project that I am trying to test my nhibernate layer with using sql lite in-memory database. I'm getting the error: Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000, private void CreateSessionFactory() { _sessionFactory = Fluently .Configure() .Database(_dbType) .Mappings(m => m.FluentMappings .AddFromAssemblyOf<UserMap>()) .ExposeConfiguration(cfg => _configuration = cfg) .BuildSessionFactory(); } I'm using fluentnhibernate, and

Version as timestamp in Fluent NHibernate / SQL Server

我与影子孤独终老i 提交于 2019-12-11 18:50:39
问题 Using FNH w/ SQL Server 2008, I'm trying to add a Version as a timestamp, but running into the SQLDateTime Overflow error because the value is passed as 1/1/0001 12:00:00 AM. I found this (also referenced here), but still experiencing the problem. // entity base public abstract class EntityBase { public virtual Int64 Id { get; set; } public virtual DateTime Version { get; set; } } // entity base map public abstract class EntityBaseMap<T> : ClassMap<T> where T : EntityBase { public

Fluent Nhibernate composed entity, specify foreign key

╄→гoц情女王★ 提交于 2019-12-11 17:52:26
问题 I have a Fluent Nhibernate map like : public class UserMap : ClassMap<PortalUser> { public UserMap() { WithTable("aspnet_Users"); Id(x => x.Id, "UserId") .GeneratedBy.Guid(); Map(x => x.Name, "UserName"); Map(x => x.Login, "LoweredUserName"); WithTable("LdapUsers", m => m.Map(x => x.FullName, "FullName")); } } My foreign key column in table "LdapUser" is UserId but the select that gets generated is going to look for a "PortalUserId". Is there a way to specify the relation key direcly? 回答1:

NHibernate Many To Many

妖精的绣舞 提交于 2019-12-11 17:49:56
问题 I have a many to many relationship between Portfolio and PortfolioTags A portfolio Item can have many PortfolioTags I am looking at the best way of saving tags to a portfolio item. My Nhibnerate maps are like so: public class PortfolioMap : ClassMap<Portfolio> { public PortfolioMap() { Table("Portfolio"); LazyLoad(); Id(x => x.Id).GeneratedBy.Identity().Column("Id"); Map(x => x.AliasTitle).Column("AliasTitle").Not.Nullable(); Map(x => x.MetaDescription).Column("MetaDescription").Not.Nullable(

connect to Sybase IQ with NHibernate

不羁岁月 提交于 2019-12-11 16:45:29
问题 I want to connect to a Sybase IQ database, which is lying on a server via Fluent NHibernate: I use C# with the NHibernate version 3.3.1.4 I am using the code from here: http://pwigle.wordpress.com/2008/11/21/nhibernate-session-handling-in-aspnet-the-easy-way/ I have tried to adopt the construktor to this: private SessionManager() { sessionFactory = Fluently.Configure() .Database(SQLAnywhereConfiguration.SQLAnywhere11.ConnectionString("server=SERVER_NAME:PORT; user=USER_NAME; password=PASSWORD

Creating trend data from data that has start and end date spaning days

风格不统一 提交于 2019-12-11 15:35:40
问题 I'm using C#, NHibernate, Fluent NHibernate and LINQ (repository pattern). Fictional story on what I want to do Say I have a car parking place, so I have a car that is renting a space from date until date. This becomes one entry into the database. I would like to find out how many cars there were for each day over the period of last 30 days. So data that can be used in a trend chart. Description What I have is entries in the database that are like so: Entry: -------- ID StartDate EndDate I