nhibernate

Can NHibernate persist to flat files instead of database?

亡梦爱人 提交于 2019-12-30 06:16:16
问题 Here is a curiousity question. I have an application that must support both flat files and the database as a place to persist data. I was thinking maybe using a .csv or tab-delimited set of files as input ... Is it possible to use NHibernate to write to do both persistance tasks? 回答1: Try using the Jet engine (see this) Dialect and other nhibernate settings should be the ones for Microsoft Access. 回答2: No not to the best of my knowledge. I have the same requirement and have ended up just

What is the best NHibernate cache L2 provider?

邮差的信 提交于 2019-12-30 04:56:27
问题 I've seen there is a plenty of them. NCache, Velocity and so forth but I haven't found a table comparing them. What's the best considering the following criterias: Easy to understand. Is being maintained lately. Is free or has a good enough free version. Works. 回答1: I can't speak for what's best or worst, but I'll throw in my experience with NCache in case it helps. Disclaimer: NHibernate and I had some disagreements, we have since gone our separate ways :) The Good The performance was great

Fluent NHibernate Many to one mapping

筅森魡賤 提交于 2019-12-30 04:55:09
问题 I am new to Hibernate world. It may be a silly question, but I am not able to solve it. I am testing many to One relationship of tables and trying to insert record. I have a Department table and Employee table. Employee and Dept has many to One relationship here. I am using Fluent NHibernate to add records. All codes below. Pls help SQL Code create table Dept ( Id int primary key identity, DeptName varchar(20), DeptLocation varchar(20) ); create table Employee ( Id int primary key identity,

Nhibernate LINQ DateTime.AddDay does not work

老子叫甜甜 提交于 2019-12-30 03:16:34
问题 I need to compare two DateTime properties in a linq query, similar to the one below - var patients = from c in session.Query<Patient>() where c.DateAdded.AddDays(1) < c.AdmitDate select c; when I run the query I get this exception: System.NotSupportedException {"System.DateTime AddDays(Double)"} at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitMethodCallExpression(MethodCallExpression expression) I took a look at Fabio's article on http://fabiomaulo.blogspot.com/2010/07

NHibernate PreUpdate event listener not persisting changes

寵の児 提交于 2019-12-29 08:52:10
问题 We have the following PreUpdate event listener: public bool OnPreUpdate(PreUpdateEvent @event) { BaseBO entity = @event.Entity as BaseBO; if (entity == null) return false; var operatorName = "OpName"; var utcDateTime = DateTime.Now.ToUniversalTime(); Set(@event.Persister, @event.State, "ModifiedBy", "Fred & Barney"); Set(@event.Persister, @event.State, "ModifiedDate", utcDateTime); entity.ModifiedBy = "fred & barney"; entity.ModifiedDate = utcDateTime; return false; } private void Set

is one to one relationship bad strategy

天涯浪子 提交于 2019-12-29 08:04:09
问题 User always has one Wallet. One Wallet belongs always to one User. Since I want to separate money wallet related properties I was create Wallet object and to be able to track money transactions, ... I created public Wallet : Entity<int> { public double Amont {get; set;} public IList<MoneyTrans> Transactions {get; set;} } Since this is obviously one to one relationship is it ok to map using one to one relationship? Is one to one bad strategy? 回答1: I had to append answer, with opposite point of

is one to one relationship bad strategy

百般思念 提交于 2019-12-29 08:04:06
问题 User always has one Wallet. One Wallet belongs always to one User. Since I want to separate money wallet related properties I was create Wallet object and to be able to track money transactions, ... I created public Wallet : Entity<int> { public double Amont {get; set;} public IList<MoneyTrans> Transactions {get; set;} } Since this is obviously one to one relationship is it ok to map using one to one relationship? Is one to one bad strategy? 回答1: I had to append answer, with opposite point of

Prevent Nhibernate schemaexport from generating foreign key constraints on has many relationship

社会主义新天地 提交于 2019-12-29 05:18:26
问题 I have a mapping like this: HasMany(x => x.Orders).KeyColumn("CustomerID"); Which is causing a constraint like this to be generated by schemaexport: alter table [CustomerOrder] add constraint FK45B3FB85AF01218D foreign key (CustomerID) references [Customer] I have tried adding .NotFound.Ignore() like on a References() mapping to disable the constraint from being generated but this does not work. Can a mapping be defined that will force SchemaExport to not generate the constraint? 回答1: Figured

NHibernate paging with SQL Server

折月煮酒 提交于 2019-12-29 05:18:08
问题 When using SetFirstResult(start) and SetMaxResults(count) methods to implement paging I've noticed that the generated query only does a select top count * from some_table and it does not take the start parameter into account or at least not at the database level. It seems that if I instruct NHibernate to execute the following query: var users = session.CreateCriteria<User>() .SetFirstResult(100) .SetMaxResults(5) .List<User>(); 105 records will transit between the database server and the

Fluent NHIbernate automapping of List<string>?

二次信任 提交于 2019-12-29 04:42:20
问题 Fluent NHibernate doesn't like this, throwing an error: {"Association references unmapped class: System.String"} OK fine, I can see why this would cause a problem - but what's the best solution? I don't really want it to store a delimited list of strings in a single field, this would get ugly if my list contains many strings. I also don't really want a table 'string', for obvious reasons. I guess I can solve this by wrapping my List<string> inside a class, but this feels a little heavyweight.