The equivalent to LIKE via the LINQ to NHibernate provider is Contains. An example of a LINQ to NHibernate that will return a result set matching a search like parameter is below. IQueryable<Classname> linqLIKE = (from m in session.Query<Classname>() where m.Code.Contains(“%dex%”) orderby m.CreateDate select m); IList<Classname> ListLIKE = linqLIKE.ToList(); The above […]
Read More →Category: Open Source
Upgrade from Oracle 10g to Oracle 11g with ODP.net and NHibernate ORA-12514
Firstly, let me say that there is nothing special about this upgrade. The instructions which I wrote here will still work with an 11g database. The issue I had was more with, what is the difference between a SID and a SERVICE_NAME which is used to identify the data instance to connection to. The SID […]
Read More →Attempted overcomplicated solution for a complicated system
I was working on a system which had implemented NHibernate, primarily for its ability to support multiple DBMS, such as Oracle and MS SQL Server. The problem came up when trying to insert, specifically in regards to the ID data type. On Oracle the ID data type was NHUMBER, while on MS SQL Server the […]
Read More →LINQ generated NHibernate and Entity Framework SQL (JOIN)
In continuation of a previous blog which compared 2 simple SELECT statements between NHibernate and Entity Framework, I do the same with the joining of 2 tables together. NHibernate Figure 1 shows the LINQ to NHibernate query which selects all the data from the PostForNHibernate table, joins with the BlogForNHibernate table using the foreign key […]
Read More →NHibernate mapping experience with an ambiguous reference
Sometime things don’t always go as planned. I was making some nice progress with the process of mapping a database and all of a sudden I get the following compile time error message. Ambiguous type reference. A type named “Attribute” occurs in at least two namespaces. “Attribute” ist ein mehrdeutiger Verweis und kann “System.Attribute” oder […]
Read More →NHibernate PropertyAccessException Invalid Cast, specified cast is not valid
If you receive this error then you have probably mixed up some data types between your class (class.cs) file and your mapping (class.hbm.xlm) file. For example you have a property defined in your class file as a string and then in your mapping file as an int. To repair the PropertyAccessException Invalid Cast (check your […]
Read More →NHibernate error, incorrect syntax near the keyword
Common sense, maybe…, worthy of a blog, absolutely. I was creating an ordering system using NHibernate and the table which stored the orders was called ORDER. This resulted in an error, which I believe would come from any data retrieval source, I just happen to be using NHibernate with SQL Server and Oracle. The error […]
Read More →Updating Child records with NHibernate using HQL-IQuery and C#
I tend to overcomplicate things, I think that I do it subconsciously in an attempt to make sure I give due diligence in the search for the best solution. I had a parent child relationship mapped out using NHibernate. Something like the below where there is a one-to-many bag in the parent class and a […]
Read More →Invalid Index N For This SqlParameterCollection using NHibernate
While trying to insert parent child composite key linked into a database I received this error: Ungültiger Index N für SqlParameterCollection mit Count=8 Invalid Index N For This SqlParameterCollection with count=8 When I added the: insert=”false” attribute to the 8th property in my mapping file, the issue was resolved. Start with the ID at 0 […]
Read More →Inserting Parent Child records using NHibernate IDENTITY INSERT OFF
One of the errors I received when I was trying to get the parent child insert to work with NHibernate was: Ein expliziter Wert für die Identitätsspalte kann nicht in der ‘CHILD’-Tabelle eingefügt werden, wenn IDENTITY_INSERT auf OFF festgelegt ist Cannot insert explicit value for identity column in table ‘IdentityTable’ when IDENTITY_INSERT is set to […]
Read More →