nhibernate

MappingException: No persister for - NHibernate - Persisting an Adapter [duplicate]

我与影子孤独终老i 提交于 2020-02-15 19:59:59
问题 This question already has answers here : NHibernate.MappingException: No persister for: XYZ (15 answers) Closed 5 years ago . Well, I googled a lot, and found the same advices all there (set hbm as Embedded Resource, add hbm at hibernate.cfg, etc..), and despite of them, I still not get it. Let me explain: I wrote a Communication Dll for a ticket gate device, and there I have a configuration model class, that I use to configure that device through TCP/IP. But now, I have to persist this

MappingException: No persister for - NHibernate - Persisting an Adapter [duplicate]

岁酱吖の 提交于 2020-02-15 19:58:47
问题 This question already has answers here : NHibernate.MappingException: No persister for: XYZ (15 answers) Closed 5 years ago . Well, I googled a lot, and found the same advices all there (set hbm as Embedded Resource, add hbm at hibernate.cfg, etc..), and despite of them, I still not get it. Let me explain: I wrote a Communication Dll for a ticket gate device, and there I have a configuration model class, that I use to configure that device through TCP/IP. But now, I have to persist this

Ignore parameters when using ISQLQuery in NHibernate

北城余情 提交于 2020-02-06 03:38:02
问题 I have to execute a native sql statement with NHibernate to the database. For this, i use: var query = session.CreateSQLQuery(sql); query.ExecuteUpdate(); Now, the sql contains the character : in a Column-Alias (which I need on this way) and NHibernate is handling this with a parameter. I haven't any parameter in this sql statement. Can I define somewhere, that NHibernate should not manage parameters for this ISQLQuery? 回答1: Just use native connection for native SQL execution: var cmd =

Ignore parameters when using ISQLQuery in NHibernate

狂风中的少年 提交于 2020-02-06 03:36:31
问题 I have to execute a native sql statement with NHibernate to the database. For this, i use: var query = session.CreateSQLQuery(sql); query.ExecuteUpdate(); Now, the sql contains the character : in a Column-Alias (which I need on this way) and NHibernate is handling this with a parameter. I haven't any parameter in this sql statement. Can I define somewhere, that NHibernate should not manage parameters for this ISQLQuery? 回答1: Just use native connection for native SQL execution: var cmd =

Map SQL Query to Business object in Nhibernate

China☆狼群 提交于 2020-02-04 14:32:45
问题 I want to map SQL query to Business object using Nhibernate . There are lot fields in Employee table, but I am getting three only and want map only those one. here is my sql query <sql-query name="findEmployeesInfo"> <return alias="emp" class="Calibr.BusinessDocuments.BOs.Employee, BusinessDocuments"/> <![CDATA[ select (emp.Eid) as {emp.Id},(emp.FirstName) as {emp.FirstName},(emp.LastName) as {emp.LastName} from Employee emp ]]> </sql-query> here is I have make constructor to map those

Map SQL Query to Business object in Nhibernate

南笙酒味 提交于 2020-02-04 14:31:52
问题 I want to map SQL query to Business object using Nhibernate . There are lot fields in Employee table, but I am getting three only and want map only those one. here is my sql query <sql-query name="findEmployeesInfo"> <return alias="emp" class="Calibr.BusinessDocuments.BOs.Employee, BusinessDocuments"/> <![CDATA[ select (emp.Eid) as {emp.Id},(emp.FirstName) as {emp.FirstName},(emp.LastName) as {emp.LastName} from Employee emp ]]> </sql-query> here is I have make constructor to map those

Are there occasions when NHibernate won't return a proxy object?

百般思念 提交于 2020-02-04 02:57:47
问题 I'm learning Fluent NHibernate (and by extension, NHibernate generally). I'm using auto-mapping with some overrides, but I don't think that is important for the question (of course, if I'm wrong here I'll gladly update the question). Given an ISession (and a few more assumed variables) I can return entities by their ID: using (var session = SessionFactory.OpenSession()) { var user = session.Get<User>(userId); } My limited understanding was that NHibernate creates a proxy around the User

Is the default constructor really necessary for nhibernate to persist an object?

风格不统一 提交于 2020-02-03 08:05:27
问题 for some reason I don't wanna let user to create an instance of the object, without sending a property to the constructor but as I know the object should have default constructor and so it would be possible to create an instance with out sending requierd property. is there any way to prevent this problem? and if yes does it have any side effect? 回答1: Just use a protected default constructor: public class Product { protected Product() { } public Product(Category category) { this.Category =

Is the default constructor really necessary for nhibernate to persist an object?

℡╲_俬逩灬. 提交于 2020-02-03 08:05:14
问题 for some reason I don't wanna let user to create an instance of the object, without sending a property to the constructor but as I know the object should have default constructor and so it would be possible to create an instance with out sending requierd property. is there any way to prevent this problem? and if yes does it have any side effect? 回答1: Just use a protected default constructor: public class Product { protected Product() { } public Product(Category category) { this.Category =

Using Lite Version of Entity in nHibernate Relations?

 ̄綄美尐妖づ 提交于 2020-02-03 05:29:05
问题 Is it a good idea to create a lighter version of an Entity in some cases just for performance reason pointing to same table but with fewer columns mapped. E.g If I have a Contact Table which has 50 Columns and in few of the related entities I might be interested in FirstName and LastName property is it a good idea to create a lightweight version of Contact table. E.g. public class ContactLite { public int Id {get; set;} public string FirstName {get; set;} public string LastName {get; set;} }