nhibernate

Configure NHibernate hibernate.cfg.xml file to have more connection strings

自古美人都是妖i 提交于 2020-01-02 09:55:01
问题 My client asked the posibility to switch from a c# app from the "CURRENT" database to a TEST database or DEV database. Only one can be active at a time. In a menu file she choose DEV or TEST database. How do I configure hibernate.cfg.xml file to have more connection strings like app.config. <name="CURRENT" connectionString='User Id=u1;Data Source=CURRENT;Password=...' /> <name="DEV" connectionString='User Id=u1;Data Source=DEV;Password=...' /> <name="TEST" connectionString='User Id=u1;Data

Fluent Nhibernate - How to specify table name

 ̄綄美尐妖づ 提交于 2020-01-02 08:09:52
问题 I just started learning Nhibernate and Fluent Nhibernate. I want to specify table name when I create my mapping class. Entity name in application is "CustomerOrders" but in the oracle database, table name is "CUSTOMER_ORDERS". I learnt from googling that I can use "WithTable" to specify database table name. I am not sure how to use it and where as Vs2008 didn't find the method. Thanks 回答1: WithTable was renamed to Table for the 1.0 release. It was mentioned in the release notes (first bullet

Exposing HasMany and ManyToMany relationships as IEnumerable

橙三吉。 提交于 2020-01-02 07:35:53
问题 Currently in my entities I'm exposing my collections as an IList but I've been thinking about exposing them as a IEnumerable to prevent users from manually adding to the collections. I have specific adds for these operations so that I can make sure my bi-directional relationships stay intact. A couple questions come to mind in this scenario. If I expose them as IEnumberable does this mean I'll need an Add and Remove method for every collection that represents a relationship in my entities? Is

NHibernate loading symbols from SymbolSource.org

 ̄綄美尐妖づ 提交于 2020-01-02 07:09:21
问题 I would like to be able to debug NHibernate and I have never loaded any symbols from SymbolSource.org before. What url do I need to enter in Visual Studio to get it to load the symbols for NHibernate so that I can debug it properly? I'm running version 3.2.0.4000 of NHibernate. Edit: This is how I have it configured. I see this in the output window. Notice that it loads the symbols for Iesi.Collections but not NHibernate. 'QTAgent32.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\cwerner\TFS

NHibernate and shared web hosting

限于喜欢 提交于 2020-01-02 06:46:40
问题 Has anyone been able to get an NHibernate-based project up and running on a shared web host? NHibernate does a whole lot of fancy stuff with reflection behind the scenes but the host that I'm using at the moment only allows applications to run in medium trust, which limits what you can do with reflection, and it's throwing up all sorts of security permission errors. This is the case even though I'm only using public properties in my mapping files, though I do have some classes defined as

Disjunction on QueryOver<T> always refers to root entity

戏子无情 提交于 2020-01-02 06:14:10
问题 I'm trying to add a certain numbers of OR conditions using disjunction on X number of entities that implements a certain interface containing date information. My problem is that when the SQL is generated all my disjunction conditions points to the root entity of my QueryOver. I have created a generic method to add my conditions public static QueryOver<T,T2> AddChangedCondition<T,T2>(this QueryOver<T,T2> query, DateTime from, DateTime to, Disjunction disjunction) where T2 : IHaveDate { if

nHibernate, mapping two properties to the same class

让人想犯罪 __ 提交于 2020-01-02 06:07:22
问题 I have a Mailclass, where I want to save both the sender and the recipient as a reference to the User class; public class dbMail : Entity { public virtual int ThreadID { get; set; } public virtual dbUser From { get; set; } public virtual dbUser To { get; set; } public virtual DateTime MailDate { get; set; } public virtual string MailText { get; set; } public virtual bool IsRead { get; set; } } and the mapping: <id name="ID"> <generator class="identity" /> </id> <property name="ThreadID" />

nHibernate, mapping two properties to the same class

[亡魂溺海] 提交于 2020-01-02 06:07:11
问题 I have a Mailclass, where I want to save both the sender and the recipient as a reference to the User class; public class dbMail : Entity { public virtual int ThreadID { get; set; } public virtual dbUser From { get; set; } public virtual dbUser To { get; set; } public virtual DateTime MailDate { get; set; } public virtual string MailText { get; set; } public virtual bool IsRead { get; set; } } and the mapping: <id name="ID"> <generator class="identity" /> </id> <property name="ThreadID" />

Fluent NHibernate: Prevent class from being mapped

限于喜欢 提交于 2020-01-02 05:38:09
问题 I am sure it is a piece of cake, but I can't find it using google. I need to EXCLUDE a single class from mapping. My current configuration is: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.Is(@"Data Source=PC\SQLEXPRESS;......"))) .Mappings(m => m.AutoMappings.Add( AutoPersistenceModel.MapEntitiesFromAssemblyOf<Person2>() .Where(t => t.Namespace == "ExampleData.HumansTest") .UseOverridesFromAssemblyOf<PersonMappingOverrides>() .ConventionDiscovery

Force NHibernate to get entity that is already in persisted state / 1st level cache

拜拜、爱过 提交于 2020-01-02 05:28:13
问题 I have a service object that is responsible for some business logic validation. What it does, before issing Update to repository, is checking whether entity that it works on complies to some business rules. One of that rules that is must check is if Status property of the entity didn't change when compared to entity that is in database. Because I use repositories that share the same ISession , when I try to get entity from database, in order to get an object for comparsion: if (fromDbEntity