I am trying to reproduce this query in Criteria API. In my mappings I have a many to many between Tag and Product, but this only appears in my Tag class, i.e. the Product class has no knowledge of tags. Basically I want to find all the products that have all of a list of tags. Here is the sql I produced although it is probably possible t...
I have a collection of Answer's (IList<Answer>) and two tables(Answer and AnswerHist).
I want to do something along the lines of:
Get the current answers from db.
save(Answers, "AnswerHist");
delete(Answers, "Answer");
Answers = questions
.Select(x => new Answer(response)
{
...
I'm having some trouble getting NH to persist my object graph.
I have (something like) this:
/*Tables*/
TABLE Parent
ParentID PK
LastEventID NULL
TABLE Event
EventID PK
ParentID FK NOT NULL
//Model Classes
public class Parent
{
public List<Event> Events; //Inverse
//Denormalized bit
public Event LastEvent; ...
My company is looking to use an ORM for new development in .Net. We are currently looking at nHibernate, because of its popularity, however LLBLGen is another option that we may consider. Cost is not a primary factor. We need a solution that provides good separation of the domain model from the database, a good caching strategy, developm...
I'm getting this exception (Full exception at the bottom):
NHibernate.PropertyValueException was unhandled by user code
Message="not-null property references a null or transient
valueClearwave.Models.Encounters.Insurance.Patient"
Source="NHibernate"
EntityName="Clearwave.Models.Encounters.Insurance"
PropertyName="Patient"
I've don...
Hello,
I was wondering how people usually go about limiting the number of entities returned from a query. I know about SetMaxResults but this seems to break down as soon as joins are involved - 3 entities with each 2 children will produce 6 rows as a result. If I use SetMaxResults(3) to get only 3 entities I will only get 3 resulting ro...
We currently have a system where each client gets their own database when they sign-up. Not surprisingly this is getting out of hand.
We are preparing merge all these databases together to a single db. In order to do this we need to note which organization the row belongs. How best is this handled on the database and what pros/cons (...
I have these tables:
create table Brand
(
ID int identity(1,1),
Name varchar(100) not null unique,
primary key clustered (ID)
)
create table Product
(
ID int identity(1,1),
Name varchar(100) not null,
BrandID int not null references Brand(ID)
)
I have the respective entities in c#, namely the Brand entity has a...
In NHibernate, can I use factory to build complex aggregate object (Entity)?
If yes then how?
If not.. then what is your approach?
...
I'm pondering the use of NHibernate on a project that has a database with some degree of planned denormalization (planned by the DBAs). Reading from one set of tables and mapping one column to one property is not a problem. However when updating I'd have to map one property back to the original column in the original table plus update a ...
We are trying to create a cool API using WCF and ICriteria, for example:
[ServiceContract]
public class ProductService
{
[OperationContract]
public List<Product> Get()
[OperationContract]
public List<Product> GetByCriteria(Criteria criteria)
}
We are thinking of using the DetachedCriteria so anyone can send it and we connect this to...
I have a server that handles the database access and a client that consumes the information. The communication from the client to the server is through a WCF service.
When the NHibernate POCO is returned from the service are all the objects in the object graph serialized? If so, is there a way to change it?
I'm also thinking of not ret...
Hi All,
I have been doing some performance analysis on an application I am working on. The application is web-based (asp.net) using an old version of NHibernate (1.0) on MSSQL Server (2005).
Running profiler against the application seems to show something a little odd, in that we seem to be querying objects twice, once as a direct que...
I would like to write something like DetachedCriteria but I don't want to use the ISession or Nhibernate at all...
All I need is the implementations for ICriterion and Expression.
after writing such Criteria -> I would like to generate an Xml Query or AD-Query or maybe even Query on collection (something like the Linq2Objects)
Do you ...
I'm using nHibernate to map an object very similar to .NET's System.Web.SiteMapNode. In order to keep my object similar to this .NET object I would like to have it contain a ParentNode, PreviousSibling, NextSibling, and ChildNodes complex properties.
The table looks somewhat like this and is open to be changed:
ID (int)
Title (string...
Is it possible yet to do a one-to-one mapping with fluent nhibernate? I have the following as part of an hbm that I'm trying to convert to fluent:
<one-to-one name="Person" property-ref="FileData" constrained="true"/>
I see a OneToOnePart<OTHER> in the code but i'm not sure how or if this is used to accomplish this.
Thanks!
...
I'm working with a legacy database in Oracle and some of my tables have columns that are set to NOT-NULL that I don't want in my domain model, but, obviously, I need to specify somewhere that at least some default value is saved to the database (eg a Groups table may have a "Indentation" column thaqt always expects a char(8) value).
How...
I am using a netdatacontractserializer and a SerializationBinder to create my own runtime types for nhibernate proxies on the client side.
This all works except I am forced to assume that there is only one type by each name in the domain model. i.e. i am forced to ignore the namespace. The reason is that SerializationBinder only gives m...
I have a fairly deep object graph (5-6 nodes), and as I traverse portions of it NHProf is telling me I've got a "Select N+1" problem (which I do).
The two solutions I'm aware of are
Eager load children
Break apart my object graph (and eager load)
I don't really want to do either of these (although I may break the graph apart later ...
I have columns in my Oracle db that I use a TrimmedStringUserType for to trim text from char(x) columns.
The db has natural keys in many tables, so I'm using Assigned Ids. Many of these are char(x) columns. How, using Fluent NHibernate (or even in the xml mapping) would I use this usertype to ensure that the Ids are trimmed?
...