nhibernate

Does NHibernate support mapping from SQL Views?

Does NHibernate support mapping of SQL VIEWS? Any examples would be helpful. ...

NHibernate - flexible config files

I am using NHibernate in a DAL layer dll. Local config file(app.config) is being used for db connection. This DAL component can be used in 2 different exe's and a NUnit test harness. Business requirement from Client is to have config information reside in exe's app.config file. Is there a way to configure NHibernate to look for an ap...

How to run Nhibernate ICriteria query with setFetchMode(Lazy) when lazy=false defined in HBM?

Hi all, I'd like to run a criteria query with lazy many-to-one associations. Those associations are set as lazy="false" in the HBM. It's because we use it eagerly 90% of the project. But there are a few 'big' queries that should run as lazy="proxy". HBM: <many-to-one name="DestinationElement" class="X" column="DstElemId" not-null="tr...

nhibernate group by

I'm hoping to display a list of all of the products ordered. I can display this using the following sql statement select products.Id,count(products.Id), products.Name from Products inner join orderitems on Products.Id = orderItems.ProductId left join orders on orderItems.OrderId = orders.Id where orders.CompanyId = 27 group by products....

upgrade to NHibernate 3.0.0.1002, Table is not mapped

Yesterday, I upgraded my NHibernate application from 1.2 to 3.0. I get the following exception c.SubContractors is not mapped [SELECT count(distinct c) FROM CallUp c, c.SubContractors sc Where sc.id = :id AND c.ChildCallUp IS NULL AND c.State > 0 AND (:start_date BETWEEN c.ContractStartDate AND c.ContractEndDate OR :end_date BETWEEN c.C...

Get saved (non commited) entities with a criteria from session cache in NHibernate

Hello everyone, I'm trying to break the question down to something simple. I use nhibernate to get a list of entities via a criteria call. After that I'll update some entites and add one entity which I save (session.SaveOrUpdate(entity)). When I get a list with a criteria again I do get the entities that were changed (with changed valu...

NHibernate Collection Left Outer Join Where Clause Issue

It seems that when using the following NHibernate query, I do not get a root entity when the left outer join has no records. ICriteria critera = session.CreateCriteria(typeof(Entity)); criteria.CreateCriteria("SubTable.Property", "Property", NHibernate.SqlCommand.JoinType.LeftOuterJoin); criteria.Add(Expression.Not(Expression.Eq("Prop...

.NET 4.0 don't use medium trust, does that mean...

.NET 4.0 don't use medium trust it got a different kind of security, does that mean it's ok to use like NHibernate on hostings that support .NET 4.0? I mean straight out the gate with it no modifications with proxy. ...

NHibernate Projections, does it support projecting inner objects

Does Hibernate + NhibernateLINQ support projection of inner objects. for eg. when I try the following I get an Index out of bounds exception on Patient object on the call to Queryable.ToList() var registrations = from r in _session.Linq<Domain.Registration>().Expand("Patient") select r; var queryable = registration...

NHibernate many-to-many mapping to existing objects

I'm having some issues with a many-to-many relationship I am trying to create. The goal is to save a customer and which products they are allowed to purchase. The products are not unique to a customer and will ALWAYS exist in the database before we try to associate a customer to them. My mapping for the association currently looks lik...

nhibernate Could not initialize proxy - no Session +asp.net mvc

In action I taken some data from db. Now in view I want to take value from one field which is referenced from other table with lazyload, by I get this error: Could not initialize proxy - no Session I wonder what I can do now. public ActionResult Index() { using (NHUnitOfWork.Start()) { va...

What is NHibernate session exactly?

Hi all, It's a long time I'm working with NHibernate session through frameworks like Castle ActiveRecord but never understood what is a session exactly and how should manipulate. Can anybody help? Is there any concise resource? Thanks in Advance ...

How to convert this HQL query with QueryOver?

Hello all, I have the following HQL query: return Session.CreateQuery("from Player p where p.Sex = :teamSex and p.Visible and not exists (from PlayerInTeam pit where pit.Player = p and pit.Roster.Team = :teamId)") .SetParameter("teamId", team.Id) .SetParameter("teamSex", team.Sex) .Enumerable<Player>(); How would you writ...

parsing a dynamic collection

I have the following collection ( see image ) . I wish to parse this into List. I have tried NHibernate's "Transformers.AliasToBean" Like so var result = _session.CreateQuery(hql) .SetResultTransformer(Transformers.AliasToBean(typeof(OrderProduct))) .List(); Tho i'm gettin...

Nhibernate Criteria make dynamic query and get the row count

Hi, I am in big need of help. I am making dynamic query using Criteria: ICriteria query = session.CreateCriteria(typeof(Employee)); if (searchOptions.FirstName != null) { query.Add(Expression.Eq("FirstName", searchOptions.FirstName)); } if (!searchOptions.LastName != null) { query.Add(Expression.Eq("LastName", searchOptions.Last...

NHibernate, i invoke delete but update is invoked automatically!!

in NHibernate, i invoke delete but update is invoked automatically!! i use FluentNhibernate Automapping. ...

NHibernate eager loading one-to-many

Hi In the mapping-file I've defined a bag for Positionen. <class name="Animag.DomainModels.Models.Abrechnung, Animag.DomainModels" table="Abrechnungen" lazy="true"> <id name="ID" column="ID"> <generator class="native"/> </id> <version name="Version" column="Version"/> <many-to-one name="Kunde" column="KundeID" c...

About NHibernate's ISession

In this question, the user asks the better way to close sessions because he was having some errors. The most voted answer is Ayende's answer that says: You should always use session.Dispose(); The other are for very strange occurances Should I really always call session.Dispose()? Isn't enough to call session.Close()? ...

NHibernate eager loading one-to-many

Hi In the mapping-file I've defined a bag for Positionen. <class name="Animag.DomainModels.Models.Abrechnung, Animag.DomainModels" table="Abrechnungen" lazy="true"> <id name="ID" column="ID"> <generator class="native"/> </id> <version name="Version" column="Version"/> <many-to-one name="Kunde" column="KundeID" c...

NHibernate Validator and Null DateTime

There must be a simple solution out there, I'm trying to use NHibernate Validator attributes on my DateTime properties. If the value is null (via [NotNull]), I want it to fail validation. When I submit a null value it gets converted to 1/1/0001 12:00:00 AM and NHibernate doesn't pick that up as null. I guess I could write a custom valida...