nhibernate

Cast an IList to an IList<t> using dynamic instantiation

I am try to convert the following NHibernate query using dyanmic instantiation into an IList<t> rather than an IList. IList<AllName> allNames = (IList<AllName>)Session.CreateQuery( @"select new AllName( name.NameId, name.FirstName, origin.OriginId, origin.Description, name.Sex, name.Description, name.SoundEx ) from Name name j...

Nhibernate mapping generator

Hi, I was wondering if there is a tool to generate Nhibernate mapping and class automatically from the database, kinda what subsonic does? Thanks in advance. ...

nHibernate Criteria ---- Use of Expression.sql

I need to do a query which checks a column in a table of type integer. how can i use expression.sql(nHIbernate Criteria API) to get all the rows matches the given number. Thank you, Rey. ...

How to persist search criterias in NHibernate?

I have complex domain model with >20 tables. The requirement is to build a search criteria screen where user can select the fields, enter the criteria on any of the tables. i am pretty much able to get this working using the Criteria API in NHibernate. But the users wish to save the search criteria in the database so that they dont h...

how can i setup my nhibernate library to work in both a web and console application?

on the web application, I am using a NHibernate helper that looks up the session that was opened in a httpmodule (and committed there also). <property name="current_session_context_class">web</property> In the console application, what do I do? ...

NHibernate, VB.Net, DataSource,DetailView, BoundField,CreateQuery, a Join, how BoundField can reference column?

Basically a reference problem. I have a query that joins two tables together. There is at least one field named the same between the two (for the join). I return an IList and assign it to the datasource of control with bound fields. But It can't find the fields in the rows. Dim myQuery As IQuery = session.CreateQuery("from ...

does nhibernate create implicit transactions within a TransactionScope?

I've created an integration test to verify that a repository handles Concurrency correcly. If I run the test without a TransactionScope, everything works as expect, but if I wrap the test in a TransactionScope, I get an error suggesting that there is a sudden need for distributed transactions (which lead me to believe that there is a sec...

The unit of work pattern within a asp.net mvc application

I have been looking at this excellant blog titled "NHibernate and the Unit of Work Pattern" and have a question regarding the best place to use UnitOfWork.Start in a asp.net mvc project. My SLN is broken down into the following projects:- MVC project Repository NHibernateUnitOfWork I have an interface:- public interface INameRep...

fluent nhibernate truncate string automatically

Is there an easy way to automatically truncate strings using fluent nHibernate mappings. I would prefer to not address this the setters or a custom type, but with something in the mapping files. ...

Doing queries with NHibernate

I'm new to NHibernate, so this is a basic question.. When fetching data from the database through an NHibernate session I've only done it using the Id this far, e.g. like this: var customer = Session.Get<Customer>(customerId); But how do I fetch an object based on a property that isn't the Id? E.g. fetch a customer by search on th...

Linq to NHibernate and Group By

I'm using the current Linq provider for NHibernate (version 2.1). I have two entities: VideoGame and GameDeveloper, with a many-to-one relationship between them. I'm trying to perform a query of this sort, which counts the number of video games each game developer has: from v in session.Linq<VideoGame>() group by v.Developer into devel...

Error while binding Treeview Control with Database using NHibernate

Hi Friends, Here is the code explanation and mapping files of my application private void PopulateNodes(IList<Folder> Values, TreeNodeCollection nodes) { foreach (Folder r in Values) { TreeNode tn = new TreeNode(); tn.Text = r.folderName.ToString(); tn.Va...

Using a named query in a hbm with import class

In my MSSQL server I have a SQL view called AllFavourite. In order to load the data into my DTO class I have the following in my hbm.xml file... <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Domain.Model.Entities" assembly="Domain.Model"> <import class="AllFavourite"/>...

Whar are the best way to improve security of application?

Hello All I am using MVC and Nhibernate in my application. How can i improve security of my application using proper authentication and authorization? Right now i am using asp.net mvc authentication. ...

How to load application settings to NHibernate.Cfg.Configuration object?

How to load application settings to NHibernate.Cfg.Configuration object by using System.Configuration.ConfigurationManager from App.config? ...

Mapping an immutable structure as a component in NHibernate

I'm testing out NHibernate to be the solution to my company's ORM needs. To do this, I've produced a small test model based on a school, providing some useful edge-cases for NHibernate to handle. I'm having problems finding out how to map a custom structure as a component of an entity without using theIUserType interface. I should stres...

NHibernate fetching the superclass brings the subclasses along

Hi, i have this code to get a ClassA from the database, and ClassA is superclass of ClassB. (ClassB : ClassA) var query = from classA in GetQuerySession().Linq<ClassA>() where classA.Code.Equals(code) select classA; return query.FirstOrDefault(); ClassA and ClassB are mapped to ...

NHibernate slow mapping

My question is what can I do to determine the cause of the slowness, or what can I do to speed it up without knowing the exact cause. I am running a simple query and it appears that the mapping back to the entities is taking taking forever. The result set is 350, which is not much data in my opinion. IRepository repo = ObjectFactory.G...

Select parent and count of children in Nhibernate using Linq in the same query

I am trying to learn MVC and nHibernate by creating a simple blog application. I have a posts table and a comments table. Each post can have multiple comments. Now in my view I have to display the details of the post and the number of comments. I tried the below code (from post in DbContext.Posts where post.ScheduledDate <= DateTim...

NHibernate simple one-to-many mapping using NHibernate.Mapping.Attributes.

Can anyone provide me with a web-link which describes attribute-based simple one-to-many mapping very clearly? For example (A company can have only one country of origin. But there are many Companies in a Country): class Company { } class Country { IList<Company> Items; } ...