With employees and subordinates - I want to load an employee with the count of subordinates in one query.
public class Employee
{
public Name {get;set;}
public int NumberOfSubordinates {get;set;}
}
Resulting SQL should look like :
select e.name, (select count(*) from subordinate s where s.employee_id = e.id) NumberOfSubordin...
I'm organizing a VisualStudio 2008 solution using Fluent NHibernate and I would like to keep all the NHibernate dll dependencies buried in a "Back End" class library and let the front end Web app or Console app be ignorant of NHibernate.
My Solution structure is as follows:
BackEnd -- Class Library -- Business logic and Data Reposito...
Hi guys,
I am trying to map these entities
Messages table fields are Id generated Id,SentFrom int, sentTo int
where Sentfrom and sentTo are linked to the users table
I also have a linker table
MessageUser table with userId and MessageId
CREATE TABLE [dbo].[MessageUser](
[MessageId] [int] NOT NULL,
[UserId] [int] NOT NULL,
CONSTRA...
I have recently updated from NH2.1 to the latest trunk build. I also upgraded to the latest source code of Fluent NHibernate.
A new issue has been introduced which manifests as the following exception :
System.Data.SqlClient.SqlException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. P...
Hello,
I need a little help to map the following structure using Fluent NHibernate. The logic behind my classes is to have a question that contains a list of choices and one answer. Each answer contains a sub-list of the choices contained by the question. I hope the code below is more clear
I've minimized the code for each class to...
Hi,
I've got two objects a parent and a child list. In my fluent nhibernate mapping for the parent I want to load the list of the children.
However I want this to be conditional, a column in the child table is called "IsDeleted" and I only want to return the children where "IsDeleted" is false.
Is it possible to set up a mapping to d...
I setup a NUnit test as such:
new PersistenceSpecification<MyTable>(_session)
.CheckProperty(c => c.ActionDate, DateTime.Now);
When I run the test via NUnit I get the following error:
SomeNamespace.MapTest:
System.ApplicationException : Expected '2/23/2010 11:08:38 AM' but got
'2/23/2010 11:08:38 AM' for Property 'ActionDate'
...
I want to control my domain's interaction with a collection, so I thought I'd make the collection protected and provide a read-only wrapper around it so that the contents are visible, but I can ensure that items are not added directly to the collection.
So I have the following code:
public class MyClass
{
public virtual ICollectio...
Hi,
I've got a simple object with three properties. This links to a table with three columns, with two of the columns being primary keys (one int the other a datetime).
Whenever I try and query nhibernate I get the following error message:
could not resolve property: invdate of:Models.Invoice
Have I missed something simple in se...
I'm using Fluent NHibernate auto mapping. I need to access more than one database on the same server is it ok to override the table name with the fully qualified name. For example my connection string is configured to Db1 but I need to access table Company on Db2 on the same server. I tested the code below and it seems to work I'm just w...
Hi!
I have a database that has a one-to-one relationship modeled between a Person and a Address (that uses person id). However, I cannot find a way to make the map using NHibernate.
My table structure is the following:
PersonTable
PersonId
PersonName
PersonAge
AddressTable
PersonId
CountryName
StreetName
StateName
And I would l...
If I have the FlushMode as Never and if I do a session.Close() will the changes be persisted to the database?
Or do we have to explicitly say session.Flush() before session.Close()?
Thanks
...
I have a component that i want to store to an SQLite database.
public class Comp : Entity
{
public virtual DateTime TimeStamp { get; set; }
public virtual String Name { get; set; }
}
public class CompMap : ClassMap<Comp>
{
public CompMap()
{
Id(x => x.Id);
Map(x => x.TimeStamp);
Map(x => x.Name);...
When ever you set a string value in fluent NHibernate it alwasy sets the DB vales to Nvarchar(255), I need to store quite a lot of long string which are based on user inputs and 255 is impractical.
Just to add this is an issue with the automapper as I am using fluent NHibernate to build the database.
...
Currently I'm using Fluent NHibernate to generate my database schema, but I want the entities in a HasMany relationship to point to a different column for the reference. IE, this is what NHibernate will generate in the creation DDL:
alter table `Pony` add index (Stable_ID),
add constraint Ponies_Stable foreign key (Stable_Id)
references...
I have the following mapping:
public class LogEntryMap
{
public LogEntryMap()
{
Map.Id(x => x.Id).GeneratedBy.Identity();
Map(x => x.Context).CustomSqlType("varchar").Length(512);
}
}
However, using SchemaExport to generate the database in SQL Server 2008, the script generated ignores the length so in effec...
I am trying a very simple Fluent Nhibernate example:
SQL 2005 database with one table, VS2008 console application. The table has one record before the program starts.
I am trying to add one record, then display all records from table. Programs successfully compiles and runs without any exceptions, however no records are displayed. HBM m...
I have my NHibernateUtil class in the infrastructure layer of my application, however I arrive at a problem with this line:
...
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Computer>());
For this to work I have to expose the domain layer to the infrastructure layer. The domain layer also has access to the infrastructure layer due...
How to get Fluent NHibernate working with latest NHibernate 3.x trunk
I got the following Exception :
Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies.
EDIT :
This exception occurs in FluentNhibernate file PersistanceConfiguration
publi...
I am seeing some odd behavior from nhibernate caching and cannot understand the reasoning. I am not able to cache queries when doing select operations like
query.Select(x=>x).ToList()
but can cache when doing:
var query = session.Linq<Promoter>();
var p = query.ToList();
Both produce the same sql query and should be doign the sam...