I have created a case insensitive dictionary in C Sharp as follows . And the following code throws an exception, since the dictionary is case insensitive.
IDictionary<string, ABCentre> names = new Dictionary<string, ABCentre>(StringComparer.OrdinalIgnoreCase);
names.Add("LC001", new ABCentre());
if (names.ContainsKey("...
I am working on a project where persisted data can be flagged for deletion, but remains in the database having a column (is_deleted) set to TRUE.
This works fine using the hibernate class mapping property "where" and adding where="is_deleted = 0" to the tags. But it fails when I declare a set of sub-class elements.
This simplified exam...
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...
Is it possible to set the default order-by column to use in the NHibernate mapping file? Unless explicitly defined I want to order all specific entities by the Name column automatically.
I've seen that it can be done on collections but thats not what I'm after in this case.
...
Hi. I've referenced the following thread which works with a Session but not a StatelessSession. http://stackoverflow.com/questions/332703/nhibernate-eager-fetching-over-multiple-levels
The problem I am having is similar to the above thread. I'm getting back 4xApplications and 4xRoles. I should be getting back 1xApplication and 4xRo...
Dear ladies and sirs.
We use NHibernate as our ORM on the server side.
Sometimes, there is a need to delete an object from the database, given only the type and ID of that object. In addition, the deleted object was not fetched before (so it is not in the session cache or whatever).
Anyway, I am using the ISession.Delete(query) overlo...
Dear ladies and sirs.
I have two tables - Run and Sample, where Sample.RunId is a foreign key linking samples to their runs.
I would like to have a SampleCount property in Run, which is the number of Sample objects associated with the particular Run.
Is it possible to map such a property in NHibernate mapping of the Run type?
Thanks....
Dear All,
I am currently involved in a parts catalogue project.
To give you some background info, I have 3 nHib Entities Part, Application and Vehicle.
Part.cs
public class Part : Entity
{
public Part()
{
Quality = new PartQuality();
FitmentPosition = new FitmentPosition();
OEPartNumbers = new List<OEP...
I have an entity (UserAccount) that has a one-to-many relationship with anohter entity (AccessRight) which references again another entity (Application). All relationships are loaded lazy.
I now try to set the fetchmode for accessright to Eager and the fetchmode of Application to eager.
var criteria = DetachedCriteria.For<UserAccount>(...
Hi!
I am using NHibernate and have a many-to-many association between an Employee and a Team.
Now I want to display all Employees with the name of its Team member.
Possibility 1:
using AutoMapper and create a DTO containing the Employee properties and the name of the Team (eager load the Team)
display the DTO in the view
Possibili...
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 all,
How would I go about mapping the following in NHibernate?
My entities and ERD are below. I know how to map a many-many relationship, but dont know how to map the joining table ReportTargets to the Datapoint table. You will notice that there is no ReportTargets entity model as it is not strictly a domain entity. What is the best ...
Hi,
I have an Asp.Net MVC app and I am looking into implementing a search engine that will search for individuals. I would like to use Nhibernate Search & Lucene.Net as this will keep the index in sync when an individual is inserted or updated, resulting in changes being visible when a user runs a search.
The issue I have is what if m...
Should there be a Service Layer in Asp.net MVC between Controller and Repository? As Repository is there for only Data Access. Some business logic is leaked into Controller. This might create a problem if the same operation is used by classic Asp.Net client as we have to duplicate the logic in Controller.
...
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...
What is the best way to generate C# classes for use with Castle ActiveRecord and NHibernate given an existing database structure?
Can you recommend any of the class generation tools or is it just less hassle to write the classes by hand?
...
[Updated with mapping files]
Ran into an issue with a lazy loaded / proxied object being persisted today.
It relates to two classes, Invoice and Address. A invoice has an Address property. Both classes are setup to be lazy loaded and all methods are virtual.
In the code I do a Invoice.address = HomeCompany.address and I can verify at ...
Has anyone able to successfully used NHibernate with Oracle Lite,If yes can you tell me what do we need to mention in hibernate.cfg.xml , I mean which dialect and how do we connect to it. Thanks.
...
We have a couple of long running back-end processes that take longer than the default 30 seconds.
Our NHibernate version is 2.0.1.4000 and Spring.NET is 1.2.0.20313.
NHibernate is configured through Spring.NET this way:
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate20">
<p...
I catch the GenericADOException with InnerException.Message = "Unique key violation ...", for telling the user that the login entered is already in use.
after that I'm trying to get some date (Session.CreateCriteria) i get this error:
null id in "MyEntityType" entry (don't flush the Session after an exception occurs)
...