fluent-nhibernate

Fluent NHibernate - Create database schema only if not existing

血红的双手。 提交于 2019-12-02 20:08:40
I have an application where I use Fluent Nhibernate to create my database. This far I've been recreating the database schema each time. The code that does this is this: public NhibernateSessionFactory(IPersistenceConfigurer config) { _sessionFactory = Fluently.Configure(). Database(config). Mappings(m => m.FluentMappings.AddFromAssemblyOf<MappingsPersistenceModel>()). ExposeConfiguration(BuildSchema). BuildSessionFactory(); } private static void BuildSchema(Configuration config) { // if (DbExists(config)) // return; new SchemaExport(config).Create(false, true); } Note the " if (DbExists(config

How to get Fluent NHibernate working with NHibernate 3.x

你说的曾经没有我的故事 提交于 2019-12-02 19:32:16
How to get Fluent NHibernate working with latest NHibernate 3.x trunk I got the following Exception : Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. EDIT : This exception occurs in FluentNhibernate file PersistanceConfiguration public TThisConfiguration Cache(Action<CacheSettingsBuilder> cacheExpression) { cacheExpression(cache); return (TThisConfiguration)this; } Don't understand, FluentNHibernate is well compiled against NH 3.x The FluentNHibernate download page has stable pre-release (pre 1.2)

NHibernate: Using Fluent Nhibernate to save child objects

家住魔仙堡 提交于 2019-12-02 19:10:17
In my system, I have two entities - ShoppingCart and ShoppingCartItem. Fairly generic use-case. However, when I save my ShoppingCart, none of the items are being saved to the DB. Within my object, I create a new ShoppingCart object. ShoppingCart cart = CreateOrGetCart(); I then add an existing Product which I got from the database to the start. cart.AddItem(product); This is just a simple wrapper to add the item to the IList. public virtual void AddItem(Product product) { Items.Add(new ShoppingCartItem { Quantity = 1, Product = product }); } I then call SaveOrUpdate on the Repository

Fluent NHibernate + Lucene Search (NHibernate.Search)

穿精又带淫゛_ 提交于 2019-12-02 18:55:49
I'm using Fluent NHibernate and I would like to implement NHibernate.Search with Lucene but I can't find any examples on how to do that with Fluent NHibernate. It appears there are two steps. (According to Castle ) Set the Hibernate properties in the configuration: hibernate.search.default.directory_provider hibernate.search.default.indexBase hibernate.search.analyzer Initializing the Event Listeners to index persisted objcts configuration.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener()); configuration.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener())

NHibernate or Fluent NHibernate? [closed]

跟風遠走 提交于 2019-12-02 18:48:11
I would be interested in hearing op opinions from others regarding whether which they would choose (no 'neithers' please ;), and why. What are the downsides to using fluent? (version dependancy maybe?) Pros, Cons, Experiences etc. Andrew Bullock Fluent NHIbernate sits on top of NHibernate, so its not really a choice between the two. If youre going to use NHibernate, CHOOSE to use Fluent NH on top of it to save yourself vast amounts of effort. Fluent NHibernate is awesome, I wouldn't use NHibernate without it. You can fluently map all your entities (giving you compile time checking, and

Fluent NHibernate cannot load MySql.Data from GAC in debug mode of a test

女生的网名这么多〃 提交于 2019-12-02 18:48:09
问题 I got the following code : var cfg = new Configuration(); cfg.Configure(); FluentConfiguration config = Fluently.Configure(cfg) .Mappings( m => m.FluentMappings.AddFromAssemblyOf<InputMapping>()); s_SessionSource = new SessionSource(config); last line throws exception when I debug my unit test with following error: Could not load file or assembly 'MySql.Data' or one of its dependencies. The system cannot find the file specified. problem is it doesn't say what version it did try to use. I

How to map it? HasOne x References

喜夏-厌秋 提交于 2019-12-02 18:03:20
问题 I need to make a mapping One by One, and I have some doubts. I have this classes: public class DocumentType { public virtual int Id { get; set; } /* othes properties for documenttype */ public virtual DocumentConfiguration Configuration { get; set; } public DocumentType () { } } public class DocumentConfiguration { public virtual int Id { get; set; } /* some other properties for configuration */ public virtual DocumentType Type { get; set; } public DocumentConfiguration () { } } A

Bi-directional relationship in nhibernate 4.0

妖精的绣舞 提交于 2019-12-02 17:49:03
问题 I have a code that was working perfectly on NHibernate 3.1, but when it is not working on NHibernate 4.0 So, this is the class relations public class Employee : BaseEntity { ... public Department Dept { get; set; } } public class Department : BaseEntity { ... public IList<Employee> Employees { get; set; } } and for the mapping we have this DepartmentMap : ClassMap<Department> { Table("...."); HasMany(x => x.Employees).KeyColumn("DeptId").Not.KeyNullable(); } EmployeeMap : ClassMap<Employee> {

Class Map Generator for Fluent NHibernate

南楼画角 提交于 2019-12-02 17:30:50
Is there a Class Map generator for Fluent NHibernate? I need something like db2hbm but I want it to generate Fluent Class Maps instead of xml mappings. I am aware of AutoMapping for Fluent but that is not what I want. I want to be able to generate Class Map files from tables in database and push them to my src repository. RaRa You can do this with NHibernate Mapping Generator . You can do this with Visual NHibernate . Check the Fluent Nhibernate option on the Options screen to create FNH mapping code. LLBLGen Pro is a great tool that can do this and much more. It´s not free, but it´s worth

MS Entity Framework VS NHibernate and its derived contribs (FluentNHibernate, Linq for NHibernate)

泄露秘密 提交于 2019-12-02 16:51:05
I just read this article about the Entity Framework 4 (actually version 2). Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in comparison to NHibernate. NHibernate and its current contributions of FluentNHibernate and Linq for NHibernate by Ayende Rahien My feeling is that Microsoft is solely trying to gain terrain it has lost in favor of NHibernate when the 2nd version of NHibernate came out. Nevertheless, my concerns are the followings (not in particular order): Will EF4 tend to