Click here to Skip to main content
15,898,222 members
Everything / NHibernate

NHibernate

NHibernate

Great Reads

by Fred Song (Melbourne)
In this article, I want to show how to build a Single Page Application – MasterChef with ASP.NET Core MVC, Fluent Hibernate, and Angular JS.
by Anand Lakshminarasimhan
A full series of 8 part articles to show One-To-One, Many-To-One, Many-To-Many associations mapping using NHibernate, Using Collections With NHibernate, Inheritance Relationships Using NHibernate, Lazy Initializations/Fetches Using NHibernate.
by Enrique Albert
Azure WebSite and W8 Store App using SQL-CE, Azure SQL, Mobile Services, SignalR, EF, WebAPI and integration to Bing Maps
by Gaurav Aroraa
In this step-by-step article, we will discuss all about CRUD (Create Read Update Delete) operations with Web API using Repository pattern.

Latest Articles

by Adam Flow
A short look into the possibilities of AutoMapper's operation options
by Fred Song (Melbourne)
In this article, I want to show how to build a Single Page Application – MasterChef with ASP.NET Core MVC, Fluent Hibernate, and Angular JS.
by Member 13652889
Setup nhibernate and fluent mapping for an ASP.NET project
by Swinkaran
This practice demonstrates the basics of NHibernate and shows how to integrate NHibernate into .Net & MVC environment with an example CRUD application

All Articles

Sort by Title

NHibernate 

23 Jan 2015 by agould1
So I've looked around quite a bit for assistance to this problem as the error seems somewhat common, but I've exhausted all my options. I've tried several implementations as suggested but I just can't get past it. Here's the exact error:"Foreign key (FK6482F24702A58C9:Category [fkCategory,...
23 Jan 2015 by Wendelius
Based on the error message you getForeign key (FK6482F24702A58C9:Category [fkCategory, pkCategory])) must have same number of columns as the referenced primary key (Skill [pkSkill])The definition for the foreign key isn't as you described. Instead you have 2 columns in the foreign key...
23 Jan 2015 by agould1
Turns out there was another attempt at this same problem in the solution but the map was wrong. Once I commented out this map (as it's essentially a dead map now) everything workedusing FluentNHibernate.Mapping;using SkillsMatrix.Domain;namespace SkillsMatrix.Mapping{ public...
31 May 2013 by Mohammed Hameed
Hi Experts,Can anybody suggest me a best approach on how to generate a XML file programmatically using C# other than XmlReader/XmlWriter? (so that parsing it should be easier).Basically, it is a Xml Hbm mapping file for NHibernate. Any .NET Api available for reading/writing Hbm files...
31 May 2013 by Jignesh Khant
System.Data.DataSet ds = new System.Data.DataSet(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("Select * from demo", "Data Source=184.107.55.15;Initial Catalog=demo;User ID=sa;Password=1947"); da.Fill(ds); // Write to XML...
17 Dec 2014 by George Jonsson
You can use XmlDocument[^].XmlDocument xmlDoc = new XmlDocument();XmlElement elRoot = xmlDoc.CreateElement("body");xmlDoc.AppendChild(elRoot);XmlElement elParam = xmlDoc.CreateElement("param");XmlText elValue =...
1 Apr 2017 by Daniele Fontani, keggyy
In this article, we explain how to build a simple and easy to use log platform, keeping in mind performance ad security.
3 Mar 2013 by qasimidl
object references an unsaved transient instance - save the transient instance before flushing or set cascade action for the property to something that would make it autosave. Type: GlobalFrameWork.com._12Solutions.Global.GlobalFramework.Admin.Entity.Student_Inquiry, Entity:...
20 Aug 2018 by Jahongir Sabirov
I have several tables. I 'm using nhibernate in my desktop project. But when I try to save some data into my any of table through nhibernate it gives me following error {"An association from the table p_returnitem refers to an unmapped class: SmartWarehouse.Order"} My Preturnitementity is...
25 Nov 2011 by elad2109
I have this class: public class AttachmentLocation { #region properties public virtual Guid UserId { get; set; } public virtual Guid LocationId { get; set; } public virtual long IndexInLocation { get; set; } ...
24 Sep 2014 by Anjum.Rizwi
I also have similar problem, I am very much new to this hibernate & fluent hibernate.My table schema is like belowCREATE TABLE [dbo].[MyChildImmunisations]( [Child_id] [int] NOT NULL, [Schedule_id] [int] NOT NULL, [Status] [int] NOT NULL, CONSTRAINT [PK_MyChildImmunisations]...
2 Jun 2011 by Dr. Song Li
I searched over .... I see many advantages, but it seems that all the advantages comes from a comparison over in-line SQL. I know in-line SQL is bad. But why compare with a bad one to show the other better?If stored procedures are used (possibly exclusively), it seems none of the advantages...
5 Jun 2011 by Sander Rossel
I have been using the Entity Framework for a while now. A few advantages for me are automatic Class creation from the DB metadata and using LINQ. Also, using an ORM tool does not mean you cannot use Stored Procedures. I do not think one method is better than the other. It depends on requirements...
5 Jun 2011 by #realJSOP
One advantage is that you learn how to not expect a 3rd-party library to be a magic bullet, and that no matter what you select, there will be issues to overcome.
17 Nov 2015 by vladimir husnullin
MVC/SPA/REST in web development with Jeneva.Net
20 Dec 2021 by Adam Flow
A short look into the possibilities of AutoMapper's operation options
7 Feb 2018 by Member 13652889
Setup nhibernate and fluent mapping for an ASP.NET project
18 Jun 2014 by krish.krish
how to use nhibernate in domain driven design(ddd) application,i have smartCA project in that i have to implement nhibernate.i think the nhibernate is use in infrasture.repository section
18 Jun 2014 by Richard MacCutchan
See http://nhforge.org/[^].
19 Apr 2012 by qasimidl
i am working with UltraWebGridwhen i click on header of column for sorting its giving me error The data source 'ObjectDataSource1' does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet.here is my Source code ...
31 Jul 2012 by Nikhil_S
Hi Friends, I am a Nhibernate User.Recently i came to know about Entity Framework so i tried to write some code using it but i am facing a Problem.I need to know how mappings and Relationships need to be written in Entity framework.Please Help me.
31 Jul 2012 by Nikhil_S
I got my solution here:Basic Handling and Tips of Database Relationships in Entity Framework[^]
14 Jan 2012 by Henry He
In this article, I will explain what transparent lazy loading is and how it's implemented in NHibernate and Entity Framework.
6 Dec 2013 by siddharth629
i am Completely new for NHibernet and i want to knew how the NhiberNet Configure in web .config plzzzzzz provide some clear and simple explanation i will be very thankful to you.
6 Dec 2013 by RaisKazi
You will have to learn how Object Relation Mapping works. Have a look at below CodeProject article.NHibernate Made Simple
2 Aug 2014 by deelll
Goal:Update the current and existing data of the row in the table kund based on new data. The new data is located in the class ContactInfo.Problem:I retrieve an error message saying "No persister for: data_layer.ContactInfo". I tried locating the root problem but I failed. I don't know...
1 Mar 2013 by qasimidl
select i.*,s.firstname ,s.lastname from student_Inquiry iinner join studentdetails s oni.Student_InquiryDetail_sno != s.Student_InquiryDetail_snohow to convert it into HQLs.Student_InquiryDetail_sno (many to one )i.Student_InquiryDetail_sno (one to many )change it and...
1 Mar 2013 by DinoRondelly
http://stackoverflow.com/questions/267085/converting-sql-to-hql
19 Jun 2014 by gunaaa
Please convert sql query into nhibernate query. My query is given below.SQL Query:SELECT tbl_other_related_family.record_id ,tbl_other_related_family.related_record_idFROM tbl_recordINNER JOIN tbl_other_related_family ON tbl_other_related_family.record_id =...
13 Nov 2012 by Pepin z Hane
Hi,I have a problem with table mapping, I cannot find any error, maybe I have badly written composite-key... Table name and class name is Player_in_Tournament, there is no error...Error: Could not compile the mapping document: Player_in_Tournament.hbm.xmlWeb Form where the Exception is...
1 May 2013 by radical500
It could not compile the mapping xml documents and i dont know whythis is my cfg file ...
28 Nov 2013 by pullareddy S
hello ,i am working with NhiberNate and VB.NETi am getting "could not execute Query" error in my applicaion.my code is as follows.Public Function GetTicketStatus(ByVal tkt As String) As String Try Dim strQuery As String = "Select stat from tkt where tkt = '"...
27 Nov 2013 by Madhu Nair
The error may occur in case table does not contain rows for some conditions.
28 Nov 2013 by Maciej Los
There could be several reasons:Table tkt doesnt' existsField tkt doesn't existsField tkt is numeric data type (not varchar)Please check the name of table and field (NOTE: in a subject you have used table name: 'Table1' instead 'tkt').If tkt field is numeric data typ , you should...
3 Aug 2014 by Rasool Ahmed
I have an error exception: "could not insert select SCOPE_IDENTITY()". After certain hours of googling, I found that I have a mistake in my Mapping files. I tried all the possible solutions, but the error keeps appearing.My mapping files:public sealed class EmployeeMap :...
12 May 2016 by Sadique KT
How to convert the following SQL query to linq? ORM using Nhibernate, Mapclass is having same name of TablesSELECT Users.*,UserRole.UserRoleLinkId FROM Users LEFT OUTER JOIN UserRole ON Users.UserId=UserRole.UserRoleId and UserRole.UserId=10 where RecordType='R'help plz..
30 Dec 2013 by thatraja
Use tools like LINQPad[^] for conversion
30 Dec 2013 by Maciej Los
Have a look here: How to: Perform Left Outer Joins (C# Programming Guide)[^]
8 Aug 2013 by Mr RaV
Hello Everyone,i have multiple table in database.ProjectMaster and UserTasks are 2 table in that database.I want to know how i can perform CRUD operation with the help of NHibernate.and also want to know about mapping in nhibernatefor eg:if project P1 is data inserted and i...
8 Aug 2013 by Sampath Lokuge
Check below mentioned links for more info.CRUD with NHibernatehttp://sdesmedt.wordpress.com/2006/06/13/nhibernate-part-2-crud-with-nhibernate/[^]Testing CRUD Operations With...
16 Oct 2014 by Gaurav Aroraa
In this step-by-step article, we will discuss all about CRUD (Create Read Update Delete) operations with Web API using Repository pattern.
13 Oct 2011 by Sebastian Solnica
This article explains the details of the session management in NHibernate. It shows you how, using the debugger, you may examine session properties and check if it's opened and closed in a desired way.
4 Jul 2014 by seek weng
Hi all. I have a problem here which I need help. I'm using .net crystal report. And I need to export the datas base on the columns I selected. I hv define some columns in dataset. But how to add more columns dynamically based on the query I want? What method should I do? Currently I've get...
5 Sep 2014 by thatraja
Check theseCrystal report with Dynamic Column[^]Crystal Reports with Dynamic Number of Columns with Typed Dataset[^]Crystal Report to display dynamic columns[^]Crystal Reports - Cross-Tab - Dynamic column number, position and sub-total page number[^]
3 Mar 2013 by qasimidl
i am inserint data into sqlserver using Nhiberbateits inserting data by using Isession.Save()but also inserting null data into parent classwhat i wantjust to insert into child (many to one relation ) class not in parent class (one to many class )
26 Feb 2012 by Rohitash Kumar
I want to add a new column to the database table in the production hours using NHibernate without affecting the old data in the table. All the previous rows will have NULL for this column.
3 Mar 2013 by qasimidl
in nhibernateits giving me this errorSqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.when i am inserting data into child table where one to many relation is available(foreign key relatoinhship)and in parent class there is one to many...
3 Mar 2013 by Matej Hlatky
I think you don't have some DateTime value set and therefore you are inserting default(DateTime) value, which is 1/1/0001. SQL Server can't insert this value.
11 Apr 2013 by Aarti Meswania
this is my postgres table CREATE SEQUENCE student_id_seq;CREATE TABLE student( id integer NOT NULL default nextval('student_id_seq'), first_name character varying, CONSTRAINT student_pkey PRIMARY KEY (id ))WITH ( OIDS=FALSE);ALTER TABLE student OWNER TO...
11 Apr 2013 by Aarti Meswania
I have solve thishope it will useful to them who facing same problem...[Class(Table = "student")]public class Student{ private long _id; private string _studentname;[Id(Name = "Id", Column = "id", UnsavedValue="0" )] [Generator(1, Class = "sequence")] ...
14 Nov 2012 by Pepin z Hane
Hi,I am trying to select something from DB using NHibernate, but it throws this error: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 5Error At:IQuery query = session.CreateQuery("FROM [Player] WHERE (([Pohlavi] = 'Muž') AND ([Aktivita] = 1))...
8 Aug 2013 by Member 10004269
hello,I just want to know how we can fetch data from mpp file to our application using nhibernate and mvc.show it on our website...!!thanks in advance
19 Aug 2014 by Member 10966414
Greetings, i'm a newbie in Fluent NHibernate, and i wonder, how can i add record to database programmatically, without this:Dictionary d = new Dictionary() { blah, blah };Users u = new Users() { blah, blah };d.AddUsers(u);session.SaveOrUpdate(d);I want to add record...
27 Jan 2012 by Samer Aburabie
Fluent NHibernate Automapping for Unidirectional ManyToMany relationship
18 Nov 2014 by Member 10966414
Greetings, my entity class looks like this:public class Foo { public virtual long ID { get; set; } public virtual string Name { get; set; } public virtual Foo2 Foo2 { get; set; }}And mapping for him:public class FooMap: ClassMap{ public FooMap() ...
18 Nov 2014 by Vijay Gill
Just use Map(x=>x.Foo2ID) then, but then you lose the cascade related functionality. Using Map(x=>x.Foo2ID) you just tell NHibernate to map to that column as if it was just like any other column.
24 May 2013 by Backward91
I need to set more than one discriminate values for parent class. Is it possible to do and how?For example:PARENT_CLASSDiscriminateSubClassesOnColumn("COLUMN_NAME", "X");CHILD_CLASS_1DiscriminatorValue("Y");CHILD_CLASS_2DiscriminatorValue("Z");This is possible. But...
6 Aug 2015 by sajjad.btech
ENTITY:public partial class InsuranceApprovalInvoice : OrderInsuranceApproval { [DataMember()] public virtual PatientInvoice PatientInvoice { get; set; } } public partial class InsuranceApprovalOrder : OrderInsuranceApproval { ...
31 Oct 2016 by Ryan Zahra
Using Fluent NHibernate, I would like to check a future date with a give date. For simplicity's sake, I've reduced my code to the bare minimum below. The property "MyDate" is mapped to a column in Sql Server of type "Date". However, I've tried the same code below using the Sql Type "DateTime"...
31 Oct 2016 by Richard Deeming
The SqlFunctions will only work with LINQ to SQL; the EntityFunctions can only be invoked from Entity Framework.If you want to call a specific function from NHibernate, then you'll need to create a custom dialect:Pure Dot Net Coder: Using DateAdd with NHibernate Linq[^]Alternatively,...
1 Dec 2015 by Ryan Zahra
Hi,I'm using Fluent NHibernate in my ASP.Net project. While on my machine everything works fine, when I publish my project to my hosting server, I'm having some issues.Below is the code that I'm using:try{ var db =...
25 Mar 2012 by Doyle Raymond
Hi everyone,I'm trying to get the dataTable using NHibernate cos I need to bind dataTable in reportviewer, but NHibernate always return IList and i don't know how to convert into DataTable, so if anyone knows, pls help me!! tdsReport.Purchase.Merge(purchaseDT); // ??? how to get...
26 Mar 2012 by Mario Majčica
Try with this methodpublic static DataTable ToDataTable(this IList data) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(T)); DataTable table = new DataTable(); foreach (PropertyDescriptor prop in...
24 Mar 2012 by Varinder Raii
Hi guys , I am doing following .public static IList RetreiveAll() { IList Company = null; try { using (var Session = ClsNhiberateHelper.OpenSession()) { ...
24 Mar 2012 by Ganesan Senthilvel
Hibernate Query Language (HQL) is case sensitive. The entity name and propery name used in HQL must be in the same case in which they are specified in CFC. It is the common mistake while using HQL.Could you verify in your code?
2 Nov 2014 by shai_ni
Hi Guys,I'm trying to add a composite index to the NHibernate mapping file so I do something like: But then, when I try to generate the DB I'm...
15 Mar 2014 by Pankaj Singh
I am trying to create a join between table based on a column.Suppose Api and Data are two tables, Data table has a column 'Id' with foreign constraint to table Api.IdPlease tell me how to write query in Nhibernate for below SQL :-select * from Api join Status on Api.Id ==...
15 Mar 2014 by Abhinav S
TryHow to do Inner Join in NHibernate[^]NHibernate - Critieria Query Joins[^]
13 Mar 2012 by qasimidl
I am using Nhibernate with asp.neti have got data using HQL in Ilistbut when i bind Ilist with gridview I gives me error "customername" field not foung in selected datasiurcealthoug i define column in gridview and there is a column with same nameMy confusion is when i...
13 Jul 2014 by Member 10503105
I have a NHibernate mapping. Inside I have a second thing: ...
19 Jul 2013 by Mohammed Hameed
Hi,I have a UserControl, which is having a button. On click of this button, a popup (another usercontrol) is being opened. This popup has a Ok button. On click of this ok button popup is being closed and at that popup close event I want to get the viewModel object of this popup.The sender...
19 Jul 2013 by Naz_Firdouse
if you had set the datacontext for the child window, use like thisPopupVM vm = (sender as ChildWindow).DataContext as PopupVM;
21 Jul 2013 by Mohammed Hameed
UserControl was a content inside the contents of ChildWindow.Hence able to find it by something like this.PopupVM vm = ((((sender as ChildWindow).Content as StackPanel).Children[0] as ScrollViewer).Content as UserControl).Resources["ViewmodelKey"] as PopupVM;
20 Jul 2013 by Phani226
SELECT SUM(ISS_QTY*COST_PRICE) FROM `patient_phar_bill_details` WHERE PHAR_TRANS_ID=6i have this query .for PHAR_TRANS_ID=6 i have multiple rows in table.i need to implement this query in nhibernate DAOimplcan anyone help me please .
30 Dec 2014 by Khudha Bakhsh Mari
Hi friendsi have 3 database with same schema, i want to first database product table data and insert this table data in to remaining database product tables mean databases are individual but schema is same (may be database on individual machines but schema is same), and i am using following...
15 Jul 2014 by NguyenTrungK4a
down votefavoriteI use Nhibernate to QueryOver to SQL Server2005. How to i can join sql like ; FROM invoucher inner join invoucherdetail ON invoucher.ID=invoucherdetail.voucher inner join Warehouse ON (CASE INVoucher.EntryType WHEN IN0001; THEN INVoucher.ToWarehouse WHEN IN0002 THEN...
8 Oct 2015 by Bitto kumar
Hi Everyone,I am new to Nhibernate. i want to pass a parameter to .hbm file without using createcriteria() method here is my hbm file.
2 Jan 2017 by ManojRGEC
I am using following query to select the data using Nhibernate.var query = _session.GetNamedQuery("QueryNameFromHbmFile") .SetInt32("Col1", userId) .SetString("Col2", cropCode) ...
20 Jun 2012 by XmasCobra
The application that I am working on use NHibernate And FluentNhibernate, but when it runs the Compiler does not seem to be able to find the reference to the dlls."No Source Available" is shown, with these errors:Locating source for 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\Fluently.cs'....
4 Sep 2015 by Member 11901595
How to update schema database (add column a table) at runtime with NHibernate?
12 Mar 2012 by Varinder Raii
How to write Queries for retreving, Checking Existence, and all we do in SQL using NHIBERNATE (FLUENTNHIBERNATE)Is FluentNhibernate is used in these Queries.And Which one is better Fluent Nhibernate Mapping or XML MappingIs there any relation or should i know LINQ for learning...
21 Oct 2013 by Sadique KT
How to convert the following query to NHibernate session.Query()...??to return a list..SELECT * FROM Table2 Where CodeID IN(SELECT CodeID FROM Table1 WHERE CompanyCode = '001') ORDER BY SubCodeId ASCAny help??
8 Jan 2013 by Rupali Jadhav
Hi,I want to write one query in NHibernet. The query is as followsUpdate table1 Set Date1=(Select top 1 max(Date) from table2 where Id=", IdI don't know NHibernate so not getting how to write this query. Waiting for suggestions. Thanks.Rupali.
10 Jan 2013 by Sumit_Kumar_Sinha
http://www.dot4pro.com/nhibernate-update-query.html[^]http://nathan.whiteboard-it.com/archive/2008/07/28/nhibernate-bulk-updatesinsertsdeletes-with-named-queries.aspx[^]http://darioquintana.com.ar/blogging/2007/12/11/nhibernate-bulk-manipulation-with-sql-native/[^]http://ahmedshuhel.blogspo...
30 Aug 2015 by Saif84
I have a problem with json serialization in Posts action (Error getting value from 'DefaultValue' on 'NHibernate.Type.DateTimeOffsetType'.) Can you help me ...... public ContentResult Posts(JqInViewModel jgData) { var posts = (_blogRepository.Posts(jgData.page -...
17 Feb 2014 by Reacher7490
I want to set the Build Action of the .hbm.xml files to Embedded Resource but it doesn't work.If the Build Action is Content everything is working fine but if I change it to Embedded Resource the following error occures:An unhandled exception of type 'NHibernate.MappingException'...
30 Jul 2014 by Rasool Ahmed
Hi all,I have this exception "illegal attempt to associate a collection with two open sessions", it raises every time I save entity contains collection of children.I google it. I found that I opened two or more sessions when calling save, but I'm sure that I'm using only one session.Where...
16 Feb 2013 by qasimidl
how to define in byte[] in hbm.xmlI am using nhibernate in asp.neti have to save pdf file into sqlservedatabase fields type is in sqlserver = varbinary(MAX)in asp.net i can retrive in byte[]what to use in hbm.xml file in propety???thanks
16 Feb 2013 by Sandeep Mewara
Following CP article will explain you on how to integrate NHibernate with ASP.NET: NHibernate Best Practices with ASP.NET, 1.2nd Ed.[^]Download the sample, go through article, learn and try out!
4 Jan 2014 by richiej
HiI have been pulling my hair out on this for a couple of hours at least now.So I am using nhibernate to map my db to my code. In the DB I have table called "Product" which has a column called "ProductId" which is the primary key and also marked as an identity column in sql server...
1 Aug 2012 by freedeveloper
I read the another answer here and in the WEB but I can not found a definitive anwser about if it is possible to insert in batch mode with fluent nhibernate and ORACLE. I try this:private void InsertData(IEnumerable coplogDetailList) { var session =...
16 Oct 2015 by sahmed3
Hi,I am trying to install an nHobernate 3.3 version in my Visual Studio 2013, While trying to install with the below comand in Nuget Package Console it throws an error Add-EFProvider : Cannot bind argument to parameter 'Project' because it is null.At...
10 Aug 2011 by Artem Smirnov
Integration vs unit tests
16 Feb 2015 by Member 10789927
Hi folks,Recently I have upgraded my NHibernate library from version 3.2 to latest version 4.0.3.4000. After that - during compilation I faced an issue related to "Iesi.Collections.Generic.ISet". From details I understand that - this interface is dropped off and alternate options are...
14 Sep 2021 by Codes DeCodes
I want to use Fluent Nhibernate ORM in my C# project that needs to connect to Oracle and SQL Server database. I know that I need to create mapping file to map my C# objects to database objects but what I am uncertain is - Is mapping syntax going...
16 Apr 2012 by qasimidl
i am working with Nhibernate,c# and asp.netIs there any way to find out the mapping file ( "hbm.xml" )exist for (" cs file " ) or notin my project there are many class (" cs file " )i need to find out of mapping file ( "hbm.xml" ) of every class (" cs file " )
8 Jul 2011 by Vijayeb
I am Using a Iset Collection in my code.This gives me an error like this operation not supported in wcf.I am using wcf test client inorder to test my methods.I am Using Nhibernate in my application to map.User.hbm.xml
26 Jan 2012 by Mastersev
I'm currently working with two tables that I'm accessing through NHibernate entity framework: - Invoices - InvoiceItemsI need to create an Invoice Items report and include the Invoice table infomration on it as well.The two tables are connected by InvoiceId. To populate my report data I...