I have an entity that is like this
public class Customer
{
public Customer() { Addresses = new List<Address>(); }
public int CustomerId { get; set; }
public string Name { get; set; }
public IList<Address> Addresses { get; set; }
}
And I am trying to query it using the Criteria API like this.
ICriteria query = m_Custo...
Hi,
I have an entity similar to the below:
public class Entity
{
public List<DateItem> PastDates { get; set; }
public List<DateItem> FutureDates { get; set; }
}
public class DateItem
{
public DateTime Date { get; set; }
/*
* Other Properties
* */
}
Where PastDates and FutureDates are both mapped to the same...
Hi!
I have defined a many to many relationship between two classes.
Event and Person (defined in a separate database table person_event).
Now, suppose I want to delete a person, so all its related associations with events must also get deleted from the person_event table. In other words, I want cascade
ON DELETE.
Lets consider a sce...
How would I go about passing a session to a repository class?
Let's say that the I have two projects.
1) TestSuite
2) BusinessObjects
The repository is contained in the BusinessObjects project. The NHibernate session is opened in the TestSuite project. Now, I want to use the same session since the TestSuite project starts a transa...
I'm attempting to use Windsor and NHibernate in a medium trust environment and I'm running up against some problems with permissions. I have read through the other questions on this but I'm using Windsor's NHibernate facility which I haven't seen discussed.
For some reason there is a dependency on the Castle.Service.Transations assembly...
I am having a problem with fluent nhiberbate mapping two tables to one class.
I have the following database schema:
TABLE dbo.LocationName
(
LocationId INT PRIMARY KEY,
LanguageId INT PRIMARY KEY,
Name VARCHAR(200)
)
TABLE dbo.Language
(
LanguageId INT PRIMARY KEY,
Locale CHAR(5)
)
And want to build the following class def...
I've been getting some extremely bizarre behaviour where NHibernate queries start to hang. I've made a demo project that exhibits this behaviour in a repeatable fashion.
You can download the project here
Here's the offending code:
public IList<Post> GetLatestLiveBlogEntries(int numEntriesToRetrieve)
{
var maxDate = Dat...
I can't seem to get the value of a select list to populate the value of the parent object.
I'm using a wrapper object to bind to so that I have access to the values needed for the SelectList as well as the object which needs the value.
I'm willing to bet I'm missing something basic but I can't find it.
I have these models:
public c...
Hello! I'm currently developing an ASP.NET Human Resources System. I'm using a layered architecture with Web Client Software Factory, which is based on MVP pattern. ORM is NHibernate. And I need to implement an Audit Log module. I've read a lot about different approaches. Most of them describe how to track date, timastamp and identity of...
I have 2 classes in a many-to-many relationship, each with an ICollection of the other:
public class Person {
public ICollection<Building> Buildings { get; private set; }
}
public class Building {
public ICollection<Person> People { get; private set; }
}
In the mapping file, they're declared as many-to-many:
<class name="Person" ...
I am using the latest NHibernate 2.1.0Beta2. I'm trying to unit test with SQLite and have the configuration set up as:
Dictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
properties.Add("dialect", "NHibernate.Dia...
I'm using StructureMap as my IoC container and NHibernate as my ORM. I found an example online that shows how to have StructureMap build the ISessionFactory and the ISession so the Factory is a singleton and the Session is based on the HttpContext. This works great, but then I started using NH Profiler which told me I should always be ex...
I have the following mapping:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-mapping
assembly='Core'
namespace='Core.Models'
xmlns='urn:nhibernate-mapping-2.2'>
<class name='Basket'>
<id name='Id'
column='id'>
<generator class='native'/>
</id>
<property name="ExternalId" />
<map name="I...
I would like to format a blog archive like below given Year=2008 and Month=2 (February):
2009
2008
March
February
Article C
Article B
Article A
January
2007
I have the following classes:
public class BlogArchive {
public int Year { get; set; }
public int Month { get; set; }
public List<BlogYear> Years { get; set; }
}...
does nhibernate parse xml files everytime someone makes a request or just once when the application starts ?
well here is what i m doing :
public class SessionManager
{
private readonly ISessionFactory _sessionFactory;
public SessionManager()
{
_sessionFactory = GetSessionFactory();
}
public ISession GetS...
Hi,
I have a scenario where I need to do the following in a transaction:
1. Save a model with a unique key
2. Delete that model
3. Save a new model with the same unique key the first one had.
I'd expect this to work just fine, but I get a unique key violation.
NH Profiler also shows that the delete statement is not issued before the s...
Does anyone have a good approach towards unit testing their UserTypes?
By way of example, I have an object in my model called DateRange, which has a DatePoint start and DatePoint end. In addition to making range type operations available for two DateTimes, these objects let me adjust the precision for the task at hand (i.e., Day, Hour, ...
I want to track changes in my domain model. I know that NHibernate ISession is an inmplementation of UnitOfWork pattern, so it tracks this changes. Is there any way to pull out them, for example, before Commit() or Flush()?
...
I am trying to implement my object hierarchy in one table with the "table per class hierarchy" strategy in NHibernate. I'm getting an error with my NHibernate mapping that can be easily reproduced with a simple example. The error is:
System.NotSupportedException: Attempting to parse a null value into an sql string (column:activity0_.T...
Hi,
I am sure it is a piece of cake, but I can't find it using google.
I need to EXCLUDE a single class from mapping. My current configuration is:
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(c =>
c.Is(@"Data Source=PC\SQLEXPRESS;......")))
.Mappings(m =>
...