Entities:
Team <-> TeamEmployee <-> Employee
Requirements:
A Team and an Employee can exist without its counterpart.
In the Team-TeamEmployee relation the Team is responsible (parent) [using later a TeamRepository].
In the Employee-TeamEmployee relation the Employee is responsible (parent) [using later an EmployeeRepository].
Duplica...
I'm trying to find out how to programmatically (i.e. without using the FieldAttribute) add an index column for NHibernate Search (Lucene.net).
I'm having inheritance issues due to the fact that the FieldAttribute is not automatically inherited.
The following code illustrates what I want to do.
class A
{
[Field(Index.Tokenized)]
...
I've got a web application with an NHibernate Data Access Layer. I have a large number of user preferences that can be stored, these are mainly booleans for example registering that a dialog has been dismissed and should not be showed again.
The problem is that with NHibernate I need to add to my database schema, and add a property to ...
I needed a way to trim strings within my persistent class because my legacy database is using char fields. I downloaded the nHhaddIns dll to use its TrimString class which is derived from IUserType.
Using their example I created a property in my mapping class as shown at the bottom.
uNHAddIns is added as a project within my solution. H...
I am using nhiberate, with the repository patter.
e.g. MakePersistance looks like:
public T MakePersistent(T entity)
{
Session.Save(entity);
return entity;
}
In a httpmodule the begin request:
ISession session = NHibernateHelper.OpenSession();
session.BeginTransaction();
CurrentSessionCon...
I'm developing a project that has multiple programs that share a single, lazy loaded SQLite database file, using Fluent Nhibernate (Auto Mapping) as the data access layer.
The first program I developed (let's call it Program 1) kept the Session open all the time, and lazy loading worked fine.
This approach failed when I got Program 2...
I have two generic save methods in a repository class:
public void Save<T>(T entity)
{
_session.Save(entity);
}
public void Save<T>(IEnumerable<T> entities)
{
foreach (var item in entities)
{
_session.Save(item);
}
}
However, when I use Save(collection) (which infers the type automatically), it recognizes it a...
Hi!
Recently I was busy implementing paging functionality with NHibernate and things went smoothly with simple entities, but I hit a performance problem with those ones where multiple joins are required to acquire the requested page. Besides that, implementation would be much simpler if the queries could be performed by convention witho...
According to this question, the most popular ORM tool for .Net is NHibernate. However, zero explanations are given. What are the compelling advantages of NHibernate over the other frameworks?
...
(See this related question for LINQ-to-SQL)
I'd like to map a class that has a URI member to a string column using NHibernate.
How exactly might I accomplish that?
I don't think the solution given to the related question works here - I can't declare a private field and map it, because the mapping needs to reference that field.
...
Is it possible to do this in NHibernate without using CreateSQLQuery. Preferably with Linq To Nhibernate. The biggest question is how do I do joins not on a primary key?
SELECT DISTINCT calEvent.* From CalendarEvent as calEvent
LEFT JOIN UserChannelInteraction as channelInteraction on channelInteraction.ChannelToFollow_id = calEvent.Cha...
I'm using Ayende's NHibernate Linq version 2.1.2, available here, and when I use NHProf to inspect queries that use this method:
public IQueryable<T> GetAll()
{
return Session.Linq<T>();
}
It gives me the warning that I'm using an implicit transaction. Problem is, I'm using this in a repository to abstract out the database session...
I have three database operations like so:
public void Add<T>(T entity)
{
using (var transaction = Session.BeginTransaction())
{
if (entity is IEnumerable)
{
foreach (var item in (IEnumerable) entity)
{
Session.Save(item);
}
}
else
{
...
would i get any performance gains if i replace my data access part of the application from nhiberate to straight ado.net ?
i know that NHibernate uses ado.net at its core !
...
I have a class StoreHours that has a composite key and has been working perfectly. A new demand came up for another type of hours to be returned. I thought "simple, I'll abstract the base class, have two concrete implementations and change my references in the app to one of the new classes". However, upon doing that, my unit tests failed...
I have a Class A:
public class ClassA
{
public int ID {get; private set;}
public string Code {get; private set;}
public ClassB B {get; private set;}
public IList<ClassB> ListB {get; private set;}
}
And a ClassB:
public class ClassB
{
public int ID {get; private set;}
public string Code {get; priva...
Hey,
I'm trying to run an NHibernate over sqlite.
i have two projects:
1. Orange.Database - holds the pocos and daos and everything else
2. Orange.GUI - holds the gui...
when the program reach to the reach the:
Configuration config = new Configuration();
config.AddAssembly("Orange.Database");
sessionFactory = config.Configure().B...
Fluent NHibernate doesnt like this, throwing an error '{"Association references unmapped class: System.String"}'. Ok fine, I can see why this would cause a problem - but whats the best solution?
I dont really want it to store a delimited list of strings in a single field, this would get ugly if my list contains many strings.
I also do...
i have an sql query that has one unnamed column as a list of strings.
my hbm is declared as follows:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Services.Data" namespace="Services.Data" >
<sql-query name="GetDiagramSubscriptions">
exec Diagram_Subscriptions:contactId
</sql-query>
</hibernate-mapping>
my r...
I said Fluent NHibernate in the subject, but I think this is an NHibernate question. However, I didn't want to confuse things by leaving out details.
I'm using Fluent NHibernate 1.0.0.593 with NHibernate 2.1.0.4000.
First a little background...
I have a base class with three implementation classes that I'm trying to map using the Di...