nhibernate

How to use LINQ to filter property of child collection using (.Any())

How do I do the following SQL in LINQ? I am actually using LINQ to NHibernate (but maybe it's not possible in NHibernate LINQ due to embedded lambda expression I think). But I want to know generally how to do it in LINQ. I’ve never came across this situation before. SELECT c.CustomerID, c.CustomerName --etc FROM Customers c INN...

Make a Nhibernate-based DAL obfuscation friendly

Hi all, I am looking to obfuscate a data access layer which is written using NHibernate. The problem is, the mappings are done in XML files which are embedded as resources in the class library - which means the mapping are in clear text. Two potential solutions are to use: 1. Nhibernate Mapping attributes (NHMA) to decorat ethe entitie...

How to uniquify resultset from NHibernate

Hi I have this multi-criteria, which works very well, except that I'm getting multiple of the same entities in the collections. I know this is by design, and I know you should be able to use a ResultTransformer to avoid it or filtering through a hashed set after quering. My query looks like this: IMultiCriteria criteria = session.Crea...

Foreign Key Constraint is preventing NHibernate from saving child record

I have two tables: SupportTicket SupportTicketID SupportTicketDate SupportTicketNote SupportTicketNoteID SupportTicketNoteDate SupportTicketID With a foreign key constraint so I don't have any unassociated Notes...in sql that constraint is working properly. On my SupportTicket class I have an IList SupportTicketNotes property...

What PHP ORM Is Most Like NHibernate?

I am looking at using an ORM in PHP for the first time. Until now my PHP projects have been fairly small and an ORM seemed like overkill. I really like NHibernate so I was hoping that there is an ORM out there for PHP that works and is configured similarly to NHibernate. If there is one with a fluent interface like Fluent NHibernate tha...

Which .NET Object Relational Mapper is fastest?

I want to use an Object Relational Mapper (ORM) tool for my ASP.NET application. I have three options: NHibernate, LINQ to SQL, and Subsonic. Which one is fastest? ...

How can I generate NHibernate mapping files and DB constructs from my domain logic?

I want to implement NHibernate on my domain objects in my project, but I'm not sure how I should go about generating the mapping file, and the database. I've found some questions that kind of touch on this here and here, but I'm starting with my classes already defined, and would like to start from them and work my way down, not the oth...

Nhibernate update on single property updates all properties in sql

I am performing a standard update in nhibernate to a single property. However on commit of the transaction the sql update seems to set all fields I have mapped on the table even though they have not changed. Surely this can't be normal behaviour in Nhibernate? Am I doing something wrong? Thanks using (var session = sessionFactory.OpenSe...

NHibernate Sorting a has many collection

Hi, I have entity Recipes and it has a HasMany collection comments. In a MVC controller action I am getting the recipe and then displaying the comments. How do I sort the comments in descending order of "EnteredOn"? Where do I sort them? Recipe recipe = session.Load<Recipe>(id); NHibernateUtil.Initialize(recipe.Comments); Ma...

Fluent nhibernate: problem in where clause

Hi, I am using fluent nhibernate. I have written a piece of code like, var data = session.CreateCriteria(typeof(CustomerNameValueList)) .Add(Expression.Eq("CustomerId","3")) .List<CustomerNameValueList>(); but the query generated by nhibernate is looks like select column1,column2,colu...

NHibernate/FluentNHibernate property bag

Given a Vehicle class and a VehicleProperty class... public class Vehicle { public virtual int Id { get; protected set; } public virtual string Registration { get; set; } private List<VehicleProperty> _properties = new List<VehicleProperty>(); public virtual IEnumerable<VehicleProperty> Properties { get { re...

Can NHibernate create tables from existing classes automatically?

I'm very new at this, but I need to create new tables from existing classes without creating them by hand. Can this be done using a tool or command line? ...

How can I relate 2 classes via NHibernate?

Let's say I have one class "User", and it "has" a property of type "Profile". How can I configure my mappings to generate the schema and create both tables in the database? ...

Nhibernate - Loading entity with HasMany collection in web app

Hi, Firstly anyone else trying to get onto forum.hibernate.org. I have been trying for a while. Can't believe its down. I am new to NHibernate. Go easy. I have an MVC app and I have an entity called Recipe and it has HasMany collections Comments, Ingredients and Images. In the action of a MVC controller I am loading the first 20 rec...

Nhibernate cursor issue

Every time i refresh the page i get the next 10 results. It is my intention to always get the same 10 items. I have the following page export.rails?items=10 Which hits the following Monorail Handler public void export(int items) { TypedPropertyBag.Delegate = delegateRepository.FindAllDelegatesIsExported(items); } ...

NHibernate SchemaExport does not create tables when "script" is false

Making my first steps with NHibernate, I'm trying to have it creating my Tables automatically from the hbm files. The database backend is SQL Server 2008 Developer Edition. This is the common sample code I see in NHibernate Tutorials: var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(Posting).Assembly); new SchemaE...

Which algoritm to use with many-to-many relation in NHibernate

I have a many-to-many relationship between photos and tags: A photo can have multiple tags and several photos can share the same tags. I have a loop that scans the photos in a directory and then adds them to NHibernate. Some tags are added to the photos during that process, e.g. a 2009-tag when the photo is taken in 2009. The Tag cla...

how do i validate date input in dd-mon-yyyy format in asp.net regularExpressionValidator?

hi everyone, I really neeed dd-mon-yy format because my oracle database accepts dates in this format. Can I validate like that in RegularExpressionValidator like that? And also, do I have to convert the textbox value to oracle data time format, when using nhibernate? thanks a lot for help; ...

NHibernate, one-to-one mapping, cascade insert

I have a one-to-one relationship between a Company class and a CompanySettings class. When I create a new Company object, (a CompanySettings object is created in Company's constructor for its Settings property), and then SaveOrUpdate(session, companyObject) I expect the INSERT to cascade from the Company to the CompanySettings. Howeve...

Simple way to create an ERD for a database design review.

I am working on a new application that uses a jet (MS Access) database. I have built the database using FluentNHibernate's AutoMapping feature from my C# objects. I need to present this database for an on-line WebEx design review on Tuesday and am looking for a tool to create ERD's for my database that I can group onto slides. The dia...