I'm a .NET developer by day, but have been working with Rails and Merb for the past year on my own side projects, so when it comes to MVC and ORMs, I'm more used to them and using ActiveRecord and DataMapper.
I'm getting started with ASP.NET MVC, and I like what I see in NHibernate and Fluent NHibernate, but looking for a little bit mor...
How to limit the number of rows returned in NHibernate?
I am looking for something like SetMaxResult(), but couldn't find it in Nhibernate namespace!
Note: I want to use NHibernate.Criterion, not NHibernate.IQuery, so it's best if you can provide that example.
...
If I were to select some rows based on certain criteria I can use ICriterion object in NHibernate.Criterion, such as this:
public List<T> GetByCriteria()
{
SimpleExpression newJobCriterion =
NHibernate.Criterion.Expression.Eq("LkpStatu", statusObject);
ICriteria criteria = Session.GetISession().CreateCriteria(typeof(T)).SetM...
I have a rather convoluted scenario/design to sort out and would much appreciate some advice or insight.
I am trying to map the following with not much success.
<class name="CalEvent" table="tb_calEvents" lazy="false" >
<id name="id" column="id">
<generator class="hilo"/>
</id>
<property name="summary"/>
---snip----
<bag name="cat...
Let's say if I encounter an error in NHibernate db update, and when such an exception is thrown, I want to log it in the log table in the db, via NHibernate again.
Now, since I can't reuse NHibernate session after an exception thrown, I will get an error when I log into the log table. How to best handle this situation?
...
We have a single database that drives a number of applications. Each application uses the same database and the same NHibernate Mappings.
I have recently implemented Nhibernate.Search in one of our applications. With a view to adding it to the others over time. If this happens I could potentially have a number of app servers updating on...
I'm using v2.1 of NHibernate.dll and NHibernate.Mappings.Attributes v2.1 in a project.
When I run the code further below, I get the following exception, and will be grateful for any pointers. On the same project, if I remove the attributes and use xml mapping files, it works fine.
NHibernate.MappingException was unhandled
Message="C...
How would one map this object to only retrieve the collection below and ignore it totally when creating or updating the object to the db?
<bag name="children" table="tb_parent_child" lazy="false">
<key column="parentID"/>
<one-to-many class="Child"/>
</bag>
thanks
...
With CSLA.net, all domain classes need to inherit from Businessbase, which contains non-virtual properties.
When using NHibernate, we need to implement virtual properties for lazy loading.
Some options to use CSLA/NHibernate together seem to be:
switch lazy loading off in NHibernate and implement lazy loading code in the domain cl...
Hi,
I just ran into a major issue for me with NHibernate. I have 2 objects, each with a collection of things. I need to move one thing from the collection from Object A to the collection of Object B. I get an error about a deleted object because, I believe, NHibernate attempts to delete the thing from the collection of Object A when it ...
I am trying to serialize a DetachedCriteria so I can save it in a database and reuse the same criteria at a later date. When I run the code below I get "NHibernate.Criterion.DetachedCriteria cannot be serialized because it does not have a parameterless constructor".
DetachedCriteria criteria1 = DetachedCriteria.For<SecurityObjectDTO>("...
I have two tables:
-- Table: medibv.btdbn
-- DROP TABLE medibv.btdbn;
CREATE TABLE medibv.btdbn
(
mabn varchar(8) NOT NULL,
hoten text,
ngaysinh timestamp,
namsinh varchar(4),
phai numeric(1) DEFAULT 0,
mann varchar(2),
madantoc varchar(2),
sonha varchar(15),
thon text,
cholam text,
matt varchar(3),
maqu varcha...
I need to use year() and month() functions in Criteria API to be able to express a business filter constrain. Expressions like
cri.Add(Expression.Ge("year(Duration.DateFrom)", Year.Value));
cri.Add(Expression.Le("year(Duration.DateTo)", Year.Value));
obviously do not work - is there any solution how to achieve this?
I know it's enti...
How would you build your domain objects and create its respective NHibernate mapping files for a multi language application. The UI part is stored in resource files but user data needs to go into the database.
I want to do the following:
Product p = DALProduct.getByID(2)
p.name //results in the language of the current UICulture
I hav...
I'm new to nHibernate, and trying to get my head around the proper way to update detached objects from a web application form POST. (We're using ASP.NET MVC)
The object I'm trying to update contains (among other things) an IList of child objects, mapped something like this:
We have arranged our MVC edit view form so t...
Assume Hibernate for the ORM.
I'm not sure how to ask this. I want to build an application that can replace part of another. For example, say I have an application with various modules, called the "big" app. This application may handle HR, financial, purchases, skill sets, etc. But maybe, for whatever reason, I don't like the skill ...
hi every one i have 2 table btdbn and benhandt and i created 2 classes Btdbn and Benhandt
CREATE TABLE medibv.btdbn
(
mabn varchar(8) NOT NULL,
hoten text,
ngaysinh timestamp,
namsinh varchar(4),
phai numeric(1) DEFAULT 0,
mann varchar(2),
madantoc varchar(2),
sonha varchar(15),
thon text,
cholam text,
matt varcha...
Hello,
I am unfamiliar with NHibernate projection. I am attempting to use it so I can return a List<> rather that an IList<>. I am not having much luck with projecting to the DTO as of yet. I have the following query and Domain objects. So to begin I am just trying to get a list of Orders given an EmployeeID. I am looping through the re...
When I execute the following query, I get an exception telling me that 'feedItemQuery' contains multiple items (so SingleOrDefault doesn't work).
This is expected behaviour when using the Criteria api WITHOUT the DistinctRootEntity transformer, but when using linq, I expect to get a single root entity (FeedItem, with the property Ads (of...
I have a Fluent Nhibernate map like :
public class UserMap : ClassMap<PortalUser>
{
public UserMap()
{
WithTable("aspnet_Users");
Id(x => x.Id, "UserId")
.GeneratedBy.Guid();
Map(x => x.Name, "UserName");
Map(x => x.Login, "LoweredUserName");
WithTable("LdapUsers", m => m.Map(...