nhibernate

NHibernate many-to-many mapping

只愿长相守 提交于 2020-01-14 03:33:08
问题 I am having an issue with many-to-many mapping using NHibernate. Basically I have 2 classes in my object model (Scenario and Skill) mapping to three tables in my database (Scenario, Skill and ScenarioSkill). The ScenarioSkills table just holds the IDs of the SKill and Scenario table (SkillID, ScenarioID). In the object model a Scenario has a couple of general properties and a list of associated skills (IList) that is obtained from the ScenarioSkills table. There is no associated IList of

NHibernate using single configuration file to connect to multiple dbs

孤街醉人 提交于 2020-01-14 02:22:08
问题 I'd like to have a single configuration file and then when I'm creating a session change the hibernate-configuration->session-factory->connection.connection_string property to what I want it to be programmatically? Is it possible? UPDATE: I believe I may be able to do this like this Configuration cfg = new Configuration(); cfg.Configure(sessionFactoryConfigPath); cfg.Properties["connection.connection_string"] = ... What I would wonder than, if that is ok, Is this a bad way to handle

nHibernate update not working for existing entity

烈酒焚心 提交于 2020-01-13 19:40:11
问题 i am trying to update record with nHibernate. I tried several solutions, but none of them work (shows no error, bu data is alsno not updated). First code: MyRepository rep = new MyRepository(GetCurrentSession()); UserPost post = rep.GetById(id); post.ValidTo = date; rep.Update(post); Second code: ISession session = GetCurrentSession(); MyRepository rep = new MyRepository(GetCurrentSession()); UserPost post = rep.GetById(id); post.ValidTo = date; rep.Update(post); session.Update(post); session

NHibernate: insert multiple items at once

浪子不回头ぞ 提交于 2020-01-13 11:26:27
问题 all! I am learning NHibernate now and I would like to know is it possible to save multiple objects to database in one operation. For example, consider this test code private static void SaveTestBillNamesInSession(ISession session, params string[] names) { var bills = from name in names select new Bill { Name = name, DateRegistered = DateTime.Now, }; foreach (var bill in bills) session.SaveOrUpdate(bill); } This loop here generates many INSERT statements which may be sub-optimal in SQL Server

Fluent NHibernate Visual Designer [closed]

北城余情 提交于 2020-01-13 10:22:11
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Is there a visual designer similar to Mindscape's NHibernate designer for Fluent NHibernate? I have decided to move from EF4 to NH3, but without a visual design interface it is going to be a hard sell to my team who are used to the EF4 model creation interface. 回答1: I've only heard of Mindscape's NHibernate

Fluent NHibernate Visual Designer [closed]

风流意气都作罢 提交于 2020-01-13 10:22:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Is there a visual designer similar to Mindscape's NHibernate designer for Fluent NHibernate? I have decided to move from EF4 to NH3, but without a visual design interface it is going to be a hard sell to my team who are used to the EF4 model creation interface. 回答1: I've only heard of Mindscape's NHibernate

How to model this situation in ORM (NHibernate)?

江枫思渺然 提交于 2020-01-13 07:08:14
问题 I've always taken a data centric approach to web apps, and so the paradigm change involved when taking a pure OO approach using ORMs is still not completely natural to me, and evey now and then something ostensibly simple is not obvious. Can someone please point me into the right direction of how to correctly model this situation in an ORM (Specifically NHibernate). The situation: There are many Users, Many Items, users may rate Items. In a data centric/relational approach it would look like

Connect NHibernate to different databases with same schema

霸气de小男生 提交于 2020-01-13 06:56:10
问题 We are in the process of splitting our db into several smaller ones. The schemas will be exactly the same and we will control which db the system connects to when the client logs in. I receive an error if I do not set a connection string in my nhibernate configuration. I do not want to create a factory for each db. Is it possible to have a session factory provide a Session that I can set the connection string before using it? 回答1: Have not used it but there is a method ChangedDatabase on the

NHibernate with nothing but stored procedures

旧时模样 提交于 2020-01-13 06:42:08
问题 I'd like to have NHibernate call a stored procedure when ISession.Get is called to fetch an entity by its key instead of using dynamic SQL. We have been using NHibernate and allowing it to generate our SQL for queries and inserts/updates/deletes, but now may have to deploy our application to an environment that requires us to use stored procedures for all database access. We can use sql-insert, sql-update, and sql-delete in our .hbm.xml mapping files for inserts/updates/deletes. Our hql and

Using SharpArchitecture's NHibernateSession in conjunction with a different thread

若如初见. 提交于 2020-01-13 05:08:52
问题 I'm using SharpArchitecture in an ASP.NET MVC 3 application. Everything works wonderfully. Using SharpArchitecture's NHibernateInitializer to initialize a new Session per request like so: protected void Application_BeginRequest(object sender, EventArgs e) { NHibernateInitializer.Instance().InitializeNHibernateOnce(InitializeNHibernateSession); } private void InitializeNHibernateSession(ISessionStorage sessionStorage) { NHibernateSession.ConfigurationCache = new