nhibernate

Transaction not connected, or was disconnected error

ぃ、小莉子 提交于 2019-12-24 16:27:31
问题 I am getting "Transaction not connected, or was disconnected error" error when the transaction is either committed/rolled back after doing a bulk insert (along with some other operations). using(var tran = Session.Session().BeginTransaction(IsolationLevel.Serializable)) { // do something fullSession.Session().CreateSQLQuery(query).ExecuteUpdate();// this query bulk insert in a temp db // do something else tran.Commit()/ tran.RollBack();// if transaction is active and not already rolled back

How to generate entity classes from nhibernate mapping files during runtime

怎甘沉沦 提交于 2019-12-24 16:20:28
问题 i need some help with c# and nhibernate. I'm working on a project that requires the entity classes to be generated from hbm files at runtime. I get the mapping files from a service, and then need to generate the classes dynamicaly and configure nhibernate to use them. The problem is that i'm new to nhibernate and not much of a pro in c#, so me writing the piece of code that achieves this is very error-prone. I was wondering if you know of any open source software that i could use. Worst case

NHibernate - Random occurrences of “Unable to locate persister”

心不动则不痛 提交于 2019-12-24 16:15:05
问题 I've seen many posts Re: the above problem (Unable to locate persister). However the problem we are having is that this error occurs randomly in our web application (ASP.Net MVC). Also when we restart the app pool the problem goes away. Mostly the error happens for an entity that is cached. See mappings below. <class name="Privilege" table="PRIVILEGE" lazy="false"> <cache usage="nonstrict-read-write"/> <id name="Id" /> <property name="Description" column="DESCRIPTION" not-null="true" /> <set

Delete Large Number of Rows Is Very Slow - SQL Server

我是研究僧i 提交于 2019-12-24 15:22:06
问题 I have database table contains around 3 millions records. When I delete large number of rows, around 400,000 records, the transaction takes forever to finish. The table is not partitioned and the database is running on Sql Server 2012 Standard Edition. I'm using Nhibernate as ORM. How do I make the transaction faster? Here the creation script of the table /****** Object: Table [dbo].[ES_DirectorDataParameters] Script Date: 03/10/2016 4:10:30 PM ******/ SET ANSI_NULLS ON GO SET QUOTED

Preloading IUserType with values from webservice

余生颓废 提交于 2019-12-24 15:14:02
问题 This post: http://kennytordeur.blogspot.com/2011/04/nhibernate-in-combination-with_06.html Describes how to load an entity from a resource other than a database, in this case a webservice. This is great, but if I load a number of clients in one query, each with a different MaritialState, it will have to call the webservice for each Client. Is there a way to preload all marital states, so it doesn't have to go back and forth to the webservice for each client? 回答1: I don't think Hibernate

NHibernate Custom IProjection that Runs a Sub-Query

我只是一个虾纸丫 提交于 2019-12-24 14:27:43
问题 Say I have 2 tables as follows: MainTable ( Id int, Name varchar(100) ) RelatedTable ( Id int, Value int, MainTableId int -- foreign key ) There is a one-to-many relationship between MainTable and RelatedTable , such that RelatedTable.MainTableId references MainTable.Id . I want to make a custom IProjection to be used as follows: sess.CreateCriteria<MainTable>() .SetProjection( Projections.ProjectionList() .Add(Projections.Property("Id")) .Add(Projections.Property("Name")) .Add(new

NHibernate MappingException. No Persister

大城市里の小女人 提交于 2019-12-24 14:17:09
问题 I'm trying to get NHibernate to work. I've got this class: mm.k.Domain.Kampagne (namespace/assembly is mm.k.Domain) In another Visual Studio project (Assembly mm.k.Infrastructure) I got my Mapping files (in a Mappings directory), my hibernate.cfg.xml and some repositories. Heres my mapping file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="mm.k.Domain" namespace="mm.k.Domain"> <class name="Kampagne" table="Kampagner"> <id name="Id">

Using NHibernate interceptor together with Ninject to retrieve the logged in user

谁说我不能喝 提交于 2019-12-24 13:33:40
问题 I was reading this article and found it quite interesting (thanks @Aaronaught). Was what came closest to solve my problem. The only detail is that in my case I would use the NHibernate interceptor, but an exception is thrown An unhandled exception of type 'System.StackOverflowException' occurred in System.Core.dll Code Session factory: public class SessionFactoryBuilder : IProvider { private ISessionFactory _sessionFactory; private readonly Configuration _configuration; public

How to bind a string to a method of an object when it is injected into another?

会有一股神秘感。 提交于 2019-12-24 13:29:43
问题 I have a NHibernate.Cfg.Configuration provider. ConfigurationProvider public class ConfigurationProvider : Provider<Configuration> { public class ConfigurationProvider(string connectionString , Assembly mappings) { ConnectionString = connectionString; Mappings = mappings; } protected override Configuration CreateInstance(IContext context) { var c = new Configuration().Configure(); c.AddAssembly(Mappings); c.Properties["connection.connection_string"] = ConnectionString; return c; } private

Using nNHibernate with Emitted Code

梦想的初衷 提交于 2019-12-24 13:26:32
问题 I am developing a software that will serve as back-end for a data-ware house, in which fact definitions will be read from an xml file and corresponding fact/dimension tables will be created on the fly. I have managed to make it work i.e. the code creates tables, updates table structure if possible otherwise drop table and make an new one, it can insert data into tables and we can query data-ware house from our client application as well. So far so good. Now I have two problems 1) Too many sql