fluent-nhibernate

Fluent nHibernate: No row with the given identifier exists. Error occurs when 2 users delete some item

♀尐吖头ヾ 提交于 2019-12-22 11:20:47
问题 Fluent nHibernate: No row with the given identifier exists. I have an Object, that has a Items collection. My problem is: Error occurs when 2 users are seeing the object and one user delete some item. The other user should see the object updated, without the deleted item, and not a Exception. I tried: session.Evict(p); // the following line will throw an exception session.Refresh(p); No row with the given identifier exists[Sistema.ERPxx.Pedidos.ItemPedido#74435] In the mapping it is specified

Cascade on delete using unidirectional Many-To-Many mapping

旧城冷巷雨未停 提交于 2019-12-22 10:55:11
问题 I am using Fluent and NHibernate. I have two objects say A & B which has a many-to-many relationship between them. I am using a unidirectional many-to-many mapping when A HasMany B's. There is no reference in B about A (Unidirectional). This creates a third table (named ABMapping) in the Database which has the two columns relating to primary keys of A & B. If I delete the object A, the entries from the ABMapping table related to A are deleted. That's cool. But, now I am not able to delete an

Fluent NHibernate mapping IList<Point> as value to single column

ぐ巨炮叔叔 提交于 2019-12-22 10:44:00
问题 I have this class: public class MyEntity { public virtual int Id { get; set; } public virtual IList<Point> Vectors { get; set; } } How can I map the Vectors in Fluent NHibernate to a single column (as value)? I was thinking of this: public class Vectors : ISerializable { public IList<Point> Vectors { get; set; } /* Here goes ISerializable implementation */ } public class MyEntity { public virtual int Id { get; set; } public virtual Vectors Vectors { get; set; } } Is it possible to map the

Fluent nHibernate - Mapping Children with Composite Keys Yielding Null References

本秂侑毒 提交于 2019-12-22 10:16:11
问题 Given a simple parent -> child (CK,CK) setup like this .. I am having trouble with adding a new child object and it getting the parent reference. So I would add the object in such a way .. var parent = new Parent{ Children = new List<Child>{ new Child{ Other = otherReference } } }; Or even adding it using the Add() method... parent.Children.Add(new Child { Other = other }); The reference to the Parent does not get pushed through. It just ends up as a null property. I get the following

Fluent NHibernate pattern for both IHttpModule and console apps

末鹿安然 提交于 2019-12-22 09:55:46
问题 I currently have a C# MVC 2 web app using Fluent NHibernate (+ LINQ) in a Repository Pattern and am using Ninject to handle the MVC controller's constructor requirement that it be passed in the repository. My Fluent NHibernate code is currently hooked into an IHttpModule, so the session can be opened and closed with the web request. This works great until I try to hook my domain model into a console app. First, I decided to move my database logic into my domain model. I'm guessing this is bad

Fluent NHibernate ignore property inside the ClassMap, using FluentMappings

亡梦爱人 提交于 2019-12-22 09:36:24
问题 I am using NHibernate 3.1 and Fluent NHibernate as ORM in my project. I need to have a property of a POCO ignored by Fluent NHibernate. At first, my post might look as exact duplicate of this question, but it is not. My complications come first from the fact that the POCOs are defined in a different assembly than the mapping and I am using fluent mappings for my POCOs. I have additional requirement not to write ingore-property code where the session factory configuration takes place (this

Default data for installation

荒凉一梦 提交于 2019-12-22 08:52:02
问题 Is it poosible to add default data to my SchemaExport. If not what's best way to do that? I would like to have one *.sql file with creation script for "tables" and "default data", or is there a better way? 回答1: I just have a little console application which calls SchemaExport and then creates default entities and calls Session.Save() on them. all I have to do to is configure the connection string on that app and run it, and.. voila! actually no .sql files needed at all, which I like. 回答2: I

Fluent / NHibernate Collections of the same class

99封情书 提交于 2019-12-22 08:37:33
问题 I am new to NHibernate and I am having trouble mapping the following relationships within this class. public class Category : IAuditable { public virtual int Id { get; set; } public virtual string Name{ get; set; } public virtual Category ParentCategory { get; set; } public virtual IList<Category> SubCategories { get; set; } public Category() { this.Name = string.Empty; this.SubCategories = new List<Category>(); } } Class Maps (although, these are practically guesses) public class CategoryMap

Is it possible to use (fluent)nhibernate with an odbc connection?

旧时模样 提交于 2019-12-22 08:34:51
问题 i have to use a custom odbc driver. All i need to pass as a connection string is the DSN. How do i do this with (fluent)nhibernate? FluentNHibernate.Cfg.Db does only offer a OdbcConnectionStringBuilder class with an DSN method. How do i use this? 回答1: You can create your own OdbcConfiguration class that derives from PersistenceConfiguration . Depending on your database, you will have to replace the Dialect in the following class. public class OdbcConfiguration : PersistenceConfiguration

Why nhibernate 3.3 doesn't allow private setter on ICollection?

百般思念 提交于 2019-12-22 08:19:01
问题 I upgraded form nhibernate 3.2 to nhibernate 3.3, and I had a lot of virtual members defined in my domain classes like this: public virtual ICollection<Movie> Movies { get; private set; } This stopped working after the upgrade and I get this exception: Following types may not be used as proxies: ClassName: method set_Movies should be 'public/protected virtual' or 'protected internal virtual' Now I managed to solve the problem by changing the setter to protected but I was surprised also that