I have a entity 'Person' a person has a collection of Friends (also Person entities)
I want to get the first 10 Friends of a particular person, ordered by LatestLogin.
My best effort is:
public static IList<Person> GetFriends(Person person, int count)
{
Person personAlias = null;
Person friendAlias = null;
...
I am using nhibernate subclass mapping to handle descriptions of objects of the system. Basically idea is to have a description class and make polymorphic associations by having sub classes specific to the object. My code inserts the description data correctly to the Database; that means the ownerid and ownertype columns are created corr...
I have a Person class. A person class contains a collection of Friends (also Person objects). A person class also has a LatestLogin property which is the LatestLogin time.
For a given person, I want to return their first 10 friends ordered by descending LatestLogin.
HQL I can do no problem:
select friends from Person person inner jo...
Hi,
I've been fighting with an NHibernate set-up for a few days now and just can't figure out the correct way to set out my mapping so it works like I'd expect it to.
There's a bit of code to go through before I get to the problems, so apologies in advance for the extra reading.
The setup is pretty simple at the moment, with just thes...
We have a fairly robust system using NHibernate, we're in the middle of migrating from a single database server to having two servers, one for administration and one for our public facing web site. This is mainly so that we can do things like content management with workflow that won’t affect the current site. As of today, they are tw...
Yes, this has been asked before here and here. I'm curious as to whether the approach I'm considering is architecturally sound.
Let me start off by trying to describe what I'd like to be able to do with my object model:
class Person {
ISet<Roles> Roles { get; set; }
}
class RoleDefinition {
string Name { get; set; }
}
class RoleA...
Hi, I'm trying to convert my data layer from Linq2Sql to nHibernate. I think Xml the configuration in nHibernate is pretty backwards so I'm using Fluent.
I've managed to get fluent, add in a repository pattern and unit of work pattern, and my unit tests are looking good.
However now as I'm plugging it into my services layer I'm noticin...
I have an application that has a core assembly with base classes that I need to inherit from.. I need to save these to the database and after reading about NHibernate decided to use it.
However I have a problem with one of my new inherited classes.. I have setup the subclass map but when I save, it neither attempts to save any of it's ...
I have a simple ASP.NET MVC + OpenID + NHibernate app (on top of MSSQL Server DB). The app is strictly single tenant and supports multiple users with only 2 roles (Admin and User).
I would like to convert this app into a multi-tenant app. My requirements are limited: I just need to introduce the notion of Accounts, each account having i...
Given the following object model
class Test
{
...
public string Name {get;set;}
public IList<Test2> Collection {get;set;} //mapped with cascade="all"
}
class Test2
{
...
public string Name {get;set;}
}
and code sample
var test = new Test();
test.Collection.Add(new Test2(){Test=test,Name="1"});
//saving new entity with N...
I have a simple Nhibernate Linq query that is returning more results than expected:
var result = (from foo in session.Linq<Foo>()
where foo.High.ID == High.ID
select foo).ToArray();
Foo looks like this:
public class Foo : DomainLayerSuperType
{
// ...other members omitted for clarity
...
hey
I have a collection of ReportColumns in a Report object.
The ReportColumns has a DisplayOrder field which sets where abouts in the report the column is displayed. these columns are re-orderable in the designer ui and i can write some hacky code to change the order of them - but was wondering if there's anyway in nhib to take care o...
I've made POCO object mapped to database like this:
class MoneyObject
{
Money MoneyAmmount { get;set; }
string Description { get;set; }
}
MoneyAmmount - is type Money which is derived from ICompositeUserType and has 2 properties decimal Amount and string CurrencyCode:
class Money
{
decimal Ammount { get;set; }
string...
Hello...
I have my class X :
public class ClassX
{
public virtual IList<ClassY> ListY { get; set; }
...
}
My ClassX mapping (using Fluent)
...
HasMany<ClassX>(x => x.ListY )
.Inverse()
.Cascade.AllDeleteOrphan()
.KeyColumns.Add("`IDX`");
...
My Y class:
public class ClassY
{
...
public...
Hi,
Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel.
I am using NHibernate to decorate my property on the domain object as below.
private decimal _refurbishmentFee;
[Min(Value=0), NotNull]
public decimal RefurbishmentFee
{
get { r...
I have two associated business objects - A and B.
the association is (A->B)many-to-one, with B.Id a foreign key in A (so A has A.B_id in the DB).
I'm using lazy=true and solved most of my problems,
however in A's ToString I want to print also A.B.Id, which I should have without further trips to the DB. but accessing A.B activates the pr...
I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error:
An association from the table xxx refers to an unmapped class.
If the tables are in the same database, then everything works fine.
...
I'm trying to use AutoMapper to map from DTO's to my Domain.
My DTO's might look like this:
public class MyDTO
{
public string Name { get; set; }
public bool OtherProperty { get; set; }
public ChildDTO[] Children { get; set;}
}
public class ChildDTO
{
public string OtherName { get; set; }
}
My Domain objects like th...
Hi All,
I am working with NHibernate, and a few code generation tools. MyGeneration is one and SmartCode is the other.
This question has been asked before, but I have looked at some other responses and found that the code generation tools in the nHibernate space to be pretty poor.
I might be able to get away with MyGeneration and Smar...
I am attempting to convert the following HQL query to Criteria.
from SubportfolioAudit as a
where a.ID in (select max(a2.ID)
from SubportfolioAudit as a2
where a2.EffectiveDate = :EffectiveDate
and a.Subportfolio.ID = a2.Subportfolio.ID
group by a2.Subportfolio.ID)
and a.Subport...