I'm learning to use NHibernate validator and it's Fluent API (Loquacious).
I have noticed is that I can't set an integer property or nullable int property (int?) to be not nullable. Well, why not?
In a database, an integer column can have null values. Even worse, when I generate DDL using SchemaExport, the integer column wont be pickin...
I have an entity called Incident and a DTO called IncidentDTO. For now, IncidentDTO simply looks like this:
public class IncidentDTO : Incident
{
// empty until I can get AutoMapper working correctly
}
I'm trying to pull a list of all the Incidents in the database and convert them to DTOs using this code:
Mapper.CreateMap<Inciden...
I'm creating an application that creates a Catalog of files. The data of the catalog will be stored in a database through NHibernate, but the actual files are just stored on a file system. I've abstracted the interface to the file system into an interface called IFileSystemAdaptor.
When an object is persisted from the database I need ...
I'm trying to do almost exactly the same thing as this post:
http://colinjack.blogspot.com/2008/03/nhibernate-working-around-lack-of.html
but I can't get the suggested solution to work for me.
Essentially I have one main class, which has a reference to an abstract class. The abstract class has several implementations. I want the comm...
I've seen many implementations on the web of people managing their NHibernate sessions and transactions in a HttpModule.
The HttpModule:
creates a session at the start of the request
wraps the whole request in a transaction
commits the transaction at the end of the request
If people use this strategy how are they handling the foll...
Hi there,
I was wondering if there is actually an existing way to work out if an object is persisted yet or not? For instance an IsPersisted(object obj) method...
Checking the identifier for an empty value would work I'm sure, but I haven't fully thought this through and just wanted to be sure there wasn't something I was missing.
Tha...
Hl Guys,
I am busy writing a backend administrative program for a system that exists. I have selected NHibernate for my data access solution and am fairly new to it. I am experiencing the following error in a parent/child relationship:
NHibernate.StaleStateException : Unexpected row count: 0; expected: 1
This error is caused by the fa...
I am trying call a db-function from HQL. The HQL statement should just call the function and return its value, like this
select someFunction(:someParameter)
If i try to call select current_timestamp()
it fails with
NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.MismatchedTreeNodeException' was thrown...
Dearest All,
I've got a many-to-many association between Lists and ListItems: a List knows about its Items, but a ListItem doesn't know about the containing lists. The cascade is saveupdate.
So, whenever I'm trying to delete a ListItem entity, I'm getting an SQLException saying I'm breaking the referential integrity. NHibernate tries t...
I have noticed, by using log4net, that when calling ISession.Update, it updates all the changed objects.
For example:
// Change 2 instances
user1.IsDeleted = true;
user2.UserName = "Xyz";
// Call session.Update to update the 2 users
using (ITransaction transaction = session.BeginTransaction())
{
Session.Update(user1); // This upd...
Looking through StackOverflow this question seems to be asked a lot, but I have tried everything listed and can't seem to get any of them to work.
I currently trying to use NHibernate in a Windows Application written in C# on .NET 4.0. My currently platform target is x86, and I have confirmed that I'm using the x86 System.Data.SQLite, ...
Imagine that I have a Parent/Child relationship managed by NHibernate.
I'm receiving a Parent object from an MVC postback that edits its properties; I want to save just the parent to the database without having to load the children from the database.
At the time of the save, Parent has a Children property that is null (because it hasn'...
Hi, I have this scenario:
public class Survey : EntityBase
{
public virtual string Name { get; set; }
}
public class Response : EntityBase
{
public virtual string Name { get; set; }
public virtual Survey Survey { get; set; }
}
public class SurveyMap : ClassMap<Survey>
{
public SurveyMap()
{
this.Id(e => e.I...
I want to disable reflection optimization (testing purposes), but i don't know where to do it. NH 2.1.2 uses hibernate-configuration in XML, and docs clearly state that this setting can not be set here. :/ I tried doing it the old App.config way with key/value pairs, no luck ...
Also, did NH 2+ version change something about reflection...
I need some tutorials on how to get started with nHibernate and Fluent nHibernate. I'm coming from an Entity Framework background (which seems easier to use). I've tried sites like http://www.summerofnhibernate.com/ to get a grasp on nHibernate itself, but it seems outdated.
I'd like to generate a mapping of my database tables (al la En...
I have an entity, with a field of type enum, that is persisted as an integer in my database.
When retrieving objects from the database using ICriteria, I wish to restrict the results to those with the field being a member of a collection of enum values. Does Restrictions.In work with a collection of enums?
The following does not work. ...
I am finding that whenever I load an object from my database it is immediately appearing as being Dirty.
I found some code that will let me see if the object is dirty here: http://nhforge.org/wikis/howtonh/finding-dirty-properties-in-nhibernate.aspx
var x = session.Get<MyRecord>(123);
var dirtyEntity = session.IsDirtyEntity(x);
dirty...
I'm using Castle ActiveRecord which uses NHibernate underneath and I've added a property with a formula as follows to one of my entities:
[Property(Formula = "CAST((select count(*) from [User] as u where u.Email = FriendEmail) as bit)")]
public bool FriendRegistered { get; set; }
The problem is that now any query for this entity fails...
I have a class, Document and several sub-classes (Invoice, PurchaseOrder, etc). I've added a discriminator to Document like so:
public class DocumentMapOverride : IAutoMappingOverride<Document>
{
public void Override(AutoMapping<Document> mapping)
{
mapping.DiscriminateSubClassesOnColumn("DocumentType");
}
}
My un...
I have 2 entities Role & Translation.
Role -> Role_ID, Code
Translation -> Code, Language, Name
The idea is to say for a certain role, that it has English name, French name and so on.
For example:
A Role(1, 'Rol_001') can have the relations: Translation('Rol_001', 'English', '') & Translation('Rol_001', 'French', '').
I would like ...