nhibernate

Fluent NHibernate error: The entity 'ClassMap`1' doesn't have an Id mapped

你。 提交于 2020-01-02 05:19:05
问题 I'm converting a previous project from using normal NHibernate hbm.xml mappings to Fluent NHibernate. Currently, I'm stuck on what should be one of the last steps to getting this working. I've added a derived class for DefaultAutomappingConfiguration to modify my ID naming convention. The string "Id" is appended to the class name: public override bool IsId(FluentNHibernate.Member member) { return member.Name == member.DeclaringType.Name + "Id"; } This should make "Agency" have an ID in a

working with Fluent NHibernate and guid ids

断了今生、忘了曾经 提交于 2020-01-02 05:08:06
问题 We're working with Fluent NHibernate 1.2 and our primary key is a guid saved in a nvarchar(32) column, working with Oracle 11gr2. How can we make this work? (making an automatic conversion...) Thanks ahead, random programmer... UPDATE: forgot to mention, the guid is saved WITHOUT dashes ... 回答1: Update: You will have to implement your own IUserType to handle the dashless Guids. You can read about it here: http://dotnet.dzone.com/articles/understanding-nhibernate-type The detail below is now

NHibernate event listeners

懵懂的女人 提交于 2020-01-02 04:55:08
问题 I'm trying to add an implementation of IPostLoadEventListener to my NHibernate configuration using FluentNHibernate. I can do so as illustrated here: how to add event listener via fluent nhibernate? However, creating a new array to replace the old one completely discards any existing event listeners. I can get around that like so: return Fluently.Configure() .Database(config) .Mappings(m => m.AutoMappings.Add(mappings)) .ExposeConfiguration(cfg => { cfg.EventListeners.PostLoadEventListeners =

Using NHibernate and Mono.Data.SQLite

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 04:52:12
问题 I read and implemented Trying to using Nhibernate with Mono & SQLite - can't find System.Data.SQLite However, as the last comment there states this seems not to work with NHibernate 3.1 The error is HibernateException: The IDbCommand and IDbConnection implementation in the assembly Mono.Data.Sqlite could not be found. Ensure that the assembly Mono.Data.Sqlite is [...reachable...] I have Mono.Data.Sqlite in the GAC. I have tried both specifying "Mono.Data.Sqlite" as well as typeof(Mono.Data

HQL to SQL converter

旧时模样 提交于 2020-01-02 04:42:25
问题 Does anyone know how to convert NHibernate HQL to SQL Scripts? 回答1: Since HQL translation depends on your mappings and also runtime behaviour, I think it is unlikely there is a way to do so statically. You could run the HQL against a real database and capture the generated SQL either via a profiler for your specific rdbms or NHProf. 回答2: My old trainings. That was beta-version. Here it is! (hql2sql.jsp) <SCRIPT type="text/javascript"> <% org.hibernate.Session ThisSession = SessionFactory

Select from Table Valued Function nhibernate

浪子不回头ぞ 提交于 2020-01-02 04:35:12
问题 I need a little help on this. I'm trying to use a table-valued function in a select, but I got the error that this is not mapped. dbo.FnListEvnt is not mapped [from dbo.FnListEvnt(:dt, :id, :code) ] Function CREATE FUNCTION [dbo].[FnListEvnt] (@DT DATETIME, @ID INT, @CODE VARCHAR (4)) RETURNS @RESULTADO TABLE ( ID INT , DT_INIC DATETIME , DT_TMNO DATETIME , CD_EVNT VARCHAR (5) ) AS BEGIN Custom Dialect (this is defined in .config ) public class CustomFunctionsMsSql2008Dialect :

NHibernate won't persist DateTime SqlDateTime overflow

隐身守侯 提交于 2020-01-02 04:13:27
问题 I am working on an ASP.NET MVC project with NHibernate as the backend and am having some trouble getting some dates to write back to my SQL Server database tables. These date fields are NOT nullable, so the many answers here about how to setup nullable datetimes have not helped. Basically when I try to save the entity which has a DateAdded and a LastUpdated fields, I am getting a SqlDateTime overflow exception. I have had a similar problem in the past where I was trying to write a datetime

Fluent NHibernate fetching view without unique identifier

前提是你 提交于 2020-01-02 01:09:32
问题 I'm trying to map a view without an identifier, but nhibernate still generates a sql with the id column (giving me a sql error, since the ID column does not exists in the db). Maybe I'm misunderstanding the Id() constructor? constructor comments: Create an Id that doesn't have a corresponding property in the domain object, or a column in the database. This is mainly for use with read-only access and/or views. Defaults to an int identity with an "increment" generator. public class

identifier of an instance of xxx was altered from y to z

爷,独闯天下 提交于 2020-01-02 00:57:17
问题 I am getting the following error when trying to update an object in a db. Does anyone have any idea what might be happening? I have checked all my datatypes and they correspond to what is in the db. Thanks for any thoughts - NHibernate.HibernateException was unhandled by user code Message="identifier of an instance of DataTransfer.status was altered from 3 to 4" Source="NHibernate" StackTrace: at NHibernate.Event.Default.DefaultFlushEntityEventListener.CheckId(Object obj, IEntityPersister

Fluent Nhibernate - Mapping a list results in NullReferenceException?

别等时光非礼了梦想. 提交于 2020-01-01 19:31:11
问题 I have the following classes and fluent mappings: public class A { public virtual int Id { get; private set; } public virtual string MyString { get; set; } public virtual IList<B> MyChildren { get; set; } } public class B { public virtual int Id { get; private set; } public virtual DateTime TheDate { get; set; } } public sealed class AMap : ClassMap<A> { public AMap() { Id(x => x.Id).GeneratedBy.Native().UnsavedValue(0); Map(x => x.MyString); HasMany(x => x.MyChildren).AsList(x => x.Column(