nhibernate

Parent Key Column Type Change in Many-to-Many Mapping

I have a join table where the original table is a numeric type and the join table key column is a string type. Legacy decision that I am trying to avoid having to change to minimize the risk to the scope of work. HasManyToMany<Attachment>(x => x.Attachments) .Table("ObjectAttachments") .ParentKeyColumn("ObjectId") .ChildKeyColumn...

NHibernate paging for Telerik Extensions for ASP.NET MVC

How can I integrate Telerik Grid paging for ASP.NET MVC (http://demos.telerik.com/aspnet-mvc/Grid) with my NHibernate data access with minimal coding? ...

NHibernate.MappingException - Trouble Shooting Checklist (no persister for)

Here's a starter list: if hbm is hand generated, is it an embedded resource? if using FNH, does it pass a PerssistenceSpecification test? if not using FNH, can you save and then load the persisted class? use Ayende's "sanity checks" I'm sure many of you have gotten this one at one point or another. But have you ever gotten it w...

NHibernate with nothing but stored procedures

I'd like to have NHibernate call a stored procedure when ISession.Get is called to fetch an entity by its key instead of using dynamic SQL. We have been using NHibernate and allowing it to generate our SQL for queries and inserts/updates/deletes, but now may have to deploy our application to an environment that requires us to use stored...

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException

I have the following code set up in my Startup IDictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect"); properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Cas...

Scalar-Valued Function in NHibernate

I have the following scalar function in MS SQL 2005: CREATE FUNCTION [dbo].[Distance] ( @lat1 float, @long1 float,@lat2 float, @long2 float ) RETURNS float AS BEGIN RETURN (3958*3.1415926*sqrt((@lat2-@lat1)*(@lat2-@lat1) + cos(@lat2/57.29578)*cos(@lat1/57.29578)*(@long2-@long1)*(@long2-@long1))/180); END I need to be able to call...

Make Fluent NHibernate output schema update to file

I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles: Public Sub UpdateBaseFiles() Dim db As SQLiteConfiguration db = SQLiteConfiguration.Standard.UsingFile(BASE_DBNAME) Fluently.Configure() _ .Database(db) _ .Mappings(Function(m) m.FluentMappings.AddFromAssemb...

Extended properties with Entity Framework or NHibernate

Hello, everyone! Is there are an easy way to store some of entitie's properties in a column as a bulk, as XML or something? Querieng by those properties of course is not an option, but it still'd be valuble to be able to extend data model without database migration. ...

Mapping a property to a field from another table in NHibernate

consider the following class: class Order { int OrderId {get; set;} int CustomerId {get; set;} string CustomerName {get; set;} //other fields go here } which is mapped to Orders table. Is it possible to map the property CustomerName to the Customers table through the foreign key relation? ...

How to query across many-to-many association in NHibernate?

I have two entities, Post and Tag. The Post entity has a collection of Tags which represents a many-to-many join between the two (that is, each post can have any number of tags and each tag can be associated with any number of posts). I am trying to retrieve all Posts which have a given tag. However, I seem to be unable to get this quer...

How can I run NHibenate queries asynchronously?

Hello, One way to increase scalability of the server application is to run IO-bound operation (reading files, sockets, web requests, database requests etc) asynchronously. This does not mean run then in the ThreadPool which will just block threads while operation is being executed. The correct way is to use asynchronous API (BeginRead, ...

Fluent nhibernate: Enum in composite key gets mapped to int when I need string

By default the behaviour of FNH is to map enums to its string in the db. But while mapping an enum as part of a composite key, the property gets mapped as int. e.g. in this case public class Address : Entity { public Address() { } public virtual AddressType Type { get; set; } public virtual User User { get; set; } ...

How does Fluent NHibernate manage to get a reference to a property using that weird delegates?

For instance, if I want to map property Title I use: > Map(x => x.Title); That's weird because this delegate is only returning the value of the property and not the property itself while NHibernate needs to know the property itself. How does it work? ...

.NET project: unified wrapper for object databases.

I am considering doing a project which would provide unified API and tools (import/export, etc.) for object databases (e.g. Caché, Objectivity) for .NET. It would provide: schema generation from CLR classes, generation of C# classes from given OODBMs schema, API for deleting, creating and updating objects, Linq provider, API for calli...

Faceted Search w/Lucene.NET & NHibernate.Search

Hi, Anyone know if it is possible to perform faceted searches with NHibernate.Search and Lucene.NET or do you need to implement something like Solr as well to get this functionality. I haven't been able to find anything regarding this in the docs. Thanks! ...

How do I get row count using the NHibernate QueryOver api?

I'm using the QueryOver api that is part of NHibernate 3.x. I would like to get a row count, but the method I'm using returns all objects and then gets the count of the collection. Is there a way to just return an integer/long value of the number of rows? I'm currently using: _session.QueryOver<MyObject>().Future().Count() ...

Nhibernate get collection by ICriteria

Hello, colleagues. I've got a problem at getting my entity. MApping: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Clients.Core" namespace="Clients.Core.Domains"> <class name="Sales, Clients.Core" table='sales'> <id name="Id" unsaved-va...

Select columns from join table only without requiring a join

Given these tables: create table Orders ( Id INT IDENTITY NOT NULL, primary key (Id) ) create table Items ( Id INT IDENTITY NOT NULL, primary key (Id) ) create table OrdersItems ( OrderId INT not null, ItemId INT not null, primary key (OrderId, ItemId) ) Is it possible to use HQL/criteria API to contruct a query...

How do I escape a LIKE clause using NHibernate Criteria?

The code we're using is straight-forward in this part of the search query: myCriteria.Add( Expression.InsensitiveLike("Code", itemCode, MatchMode.Anywhere)); and this works fine in a production environment. The issue is that one of our clients has item codes that contain % symbols which this query needs to match. The resulting SQL...

NHibernate - illegal access to loading collection error

I'm getting the error "Illegal acces to loading collection" when i'm trying to get a list of variants belonging to a certain product. The NHibernate mapping is as below; <list name="Variants" lazy="false" cascade="save-update" inverse="false" table="PluginProduct_ProductVariant"> <key column="ProductId" /> <index column="Ordinal" />...