I have a class that looks like this:
public class Job
{
public Company Company {get;set;}
public Job JobForCompanyA {get;set;}
public Job JobForCompanyB {get;set;}
}
The jobs for the two companies will reference each other, for example:
var jobA = new Job { Company = Company.CompanyA };
var jobB = new Job { Company = Comp...
Hi
I have som entities and now want to make some DTO´s based on there entities using nhibernate.
I have a Service - Allocation -Ressource where allocation describes how the ressource is allocated for the service.
I want a DTO like
ServiceDTO
-Name
-RessourceDTO
where RessourceDTO also has a name.
In the examples I have see for NH...
Hi,
From the text "The Repository" pattern is a Mediator between the Domain and Data Mapper layers. Cool. So for example, maybe there is a Repository interface and Base Domain Object like so
public interface Repository<DomainT> where DomainT : DomainObject{
DomainT Get(Object id);
}
Then a concrete implementation would be
publ...
Hi all,
I have a problem with nhibernate when I try to insert an object with an one-to-one relationship to another object. There is a class called Article
Mapping file
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<id name="ID" column="article_id" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<pr...
i have a complex entity, very very heavy.
i want to select only the id and the name of this entity from the db for a better performance.
how do i do that with nhibernate (or fluent nhibernate).
...
If I create a DTo using projection and an import mapping, is the object by default then immutable for NHibernate or is it possible to define mutable=false in the import mapping?
...
_session.CreateQuery("Select a.AuLname From Authors a Order By a.AuLname")
.List();
I must be drawing a blank here...but I cannot figure out how to return a list of author last names using the session's CreateCriteria method. Getting a distinct list of last names is not a problem as I can use a projection. But that is not what I am t...
I am replacing my old DAL with NHibernate 2.1. My NHibernate config works on my local dev machine but not on UAT. The UAT database is a cluster setup on a none default port. I am using a standard NHibernate confie file similar to below:
<?xml version="1.0" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<sessi...
I'm defining a database for a customer/ order system where there are two highly distinct types of customers. Because they are so different having a single customer table would be very ugly (it'd be full of null columns as they are pointless for one type).
Their orders though are in the same format. Is it possible to have a CustomerId co...
Hello all,
I have a situation where an XML file contains data similar to some content in database tables, and I would need to update the database to match exactly the contents of that XML file. I am wondering, if using NHibernate, or LINQ to SQL, I am able to do something like this:
Load the database content into entity objects.
Load ...
Update take 2
here is the two queries i'm working with (paging is omitted in both queries)
i'd like to get the following query
SELECT *
FROM product
LEFT OUTER JOIN
(
SELECT *
FROM Cart
LEFT OUTER JOIN
cartproducts
ON Cart.Id = cartproducts.Cart_id
WHERE Cart.username = 'user'
)
AS CartFiltered
ON produ...
I have a SQL Server DB with a recursive table:
MyTable:
ID : string PrimaryKey
Parent: string references MyTable - NOTNULL !!
and map with Fluent NHibernate to
class MyTable
{
public virtual string ID {get; set;}
public virtual MyTable Parent {get; set;}
}
My problem is that Parent should be null in my C# app if the column Pa...
Hi, I was recently hired at a Software Engineering company and was put in charge of a new project for storing our analytics data. I want to give ORM a shot the mapping doesn't seem difficult but this problem has me vexed.
This database will store data for Google Analytics, Quantcast, and any future analytics provider. I was pretty much ...
I'm trying to create a query using NHibernate and searching along multiple foreign keys:
The following code works when I'm only searching on one of the foreign keys:
ICriteria query = Session.CreateCriteria<TblTeam>()
.Add<TblTeam>(x => x.FldUrlSafeName == teamName)
.CreateCriteria<TblTeam>(x => x.TblSportsType)
.Add<Tbl...
I'm using the IPostUpdateEventListener interface to do update audit logging now, grabbing the old and new values, then storing each updated field in an "Audit" table and all that jive. Works swell, but there's two last requirements I'm having a hard time fullfilling:
Display which employee the update was for.
Display the "friendly" nam...
Hi all,
My situation is next: there are to entities with many-to-many relation, f.e. Products and Categories. Also, categories has hierachial structure, like a tree. There is need to select all products that depends to some concrete category with all its childs (branch). So, I use following sql statement to do that:
SELECT * FROM Prod...
I have a domain model object which has properties of type System.DateTimeOffset. I'm using a database which doesn't support this type natively, so I'm planning to store it using a column of type 'datetime' and one of type 'smallint'.
I've dug around on how to map this using NHibernate components, and found that it could work using an I...
First, I have the following table:
CREATE TABLE CustomerHub (
CustomerId INT NOT NULL,
HubId INT NOT NULL
)
Which I have mapped to the this entity:
public class CustomerHub
{
public int CustomerId {get;set;}
public int HubId {get;set}
//GetHashCode, Equals, Etc...
}
Using this mapping:
public class CustomerHubMap :...
I have a Person class which has a Tags property
public virtual System.Collections.Generic.List<Tag> Tags { get; set; }
which contains a collection of Tag class objects.
Given the system design, the instance of the Person class is created initially and then at a later time the user can add tags to a Person.
Being new to NHibernate I ...
I have some web methods that return my objects back as serialized XML. It is only serializing the NHibernate-mapped properties of the object... anyone have some insight? It seems to be that the web methods are actually serializing the NHibernate proxies instead of my classes. I've tried using [XMLInclude] and [XMLElement], but the pro...