Update
Well, as i was told by Stuart Charles and James Gregory, my model was weird enough to begin with. Apparently double-way references between classes while discriminating between the different kinds of relations isn't done, and apparently for a very good reason.
I tore the model down, changed it to a different one using HasManyToMa...
Hi,
Let's say I have a simple parent->child class structure as shown below
Public Class Parent
Public ParentID As Integer
Public Children As IList(Of Child)
End Class
Public Class Child
Public ChildID As Integer
Public Parent As Parent
End Class
These are mapped to two tables using Fluent NHibernate. No problem.
I now have ...
Hi all
Im really struggling with NHibernate here. I'm trying to keep my DAL-assembly very generic, so that it works in a webcontext, in WCF and in WinForms / WPF. My problem here is the sessions.
Lazy-loading is good, and something I really want, but after the session which you loaded the object with is closed, you can't lazy-load anym...
This is the first time I've used NHibernate for a big project so bear with me. Basically, I need to run a search based on 5 fields.
I want to display the results in a table. Here is a test I've written that basically gets all Clients that have Intakes with a Staff named "DII". When I run it, I get an error saying that some of the I...
I have an enum called Permissions. A user can be assigned permissions, or permissions can be asigned to a role and the user can be given a role.
User and Role both have a property like this:
public virtual IList<Permission> Permissions { get; set; }
I want to use an enum for Permissions so in my code I can do things like
public sta...
Given a class...
public class Message
{
/// key: User, value: folder name
private readonly IDictionary<User, string> _folders = new Dictionary<User, string>();
public virtual IDictionary<User, string> Folders { get { return _folders; } }
}
<map name="Folders" access="field.camelcase-underscore">
<key column="Message_id"...
When would I write a UoW implementation on top of what is already provided by NHibernate? Any real world examples?
...
Hi,
I have an interface, an abstract implementation of interface with generics and a concrete implementation.
eg.
interface IProperty
[Class(Table = "Properties", Lazy = false)]
abstract AbstractGenericProperty<T> : IProperty
[Subclass(ExtendsType = typeof(AbstractGenericProperty<string>), DiscriminatorValue = "string", Lazy = false...
I'm using NHibernate currently. I have a situation where I need to save a bunch of records to the database like this:
var relatedTopics = GetRelatedTopics(topic);
foreach (var relatedTopic in relatedTopics /* could be anywhere from 10 - 1000+ */)
{
var newRelatedTopic = new RelatedTopic { RelatedTopicUrl = relatedTopic, TopicUrl = t...
I'm having trouble saving an entity into an SQL Server 2005 database. I'm using NHibernate 2.0.0.3002 for my persistence layer. The mapping is typical, with an integer ID, as follows
<id name="Id" unsaved-value="0">
<column name="Id"/>
<generator class="identity" />
</id>
I've omitted the rest for brevity. The application is using...
Hi,
I'm developing a sample application so that I can learn the ins and outs of NHibernate. I am struggling with a delete issue. I wish to be able to delete a child record by removing it from its parent’s collection and then saving the parent. I have setup a bidirectional one-to-many relationship and inserting/updating is working great....
Code:
public IList<T> GetByMultipleIds(int[] ids)
{
List<T> result =
_session.Linq<T>()
.Where(x => ids.Contains(x.Id)).ToList();
return result;
}
Throws:
An exception of type 'System.NullReferenceException' occurred in
NHibernate.DLL but was not handled in user code
Additional inform...
Hi,
I have the following DB Table
CREATE TABLE ProductPrice
ProductID
Qty1
Price1
Qty2
Price2
Qty3
Price3
My domain classes look like this
Class ProductPrice
ProductID As Integer
PriceBands As IList(of PriceBand)
End Class
Class PriceBand
Qty As Integer
Price As Decimal
End Class
I know we can use the "compo...
With our current persistence framework properties on a child entity that point to it's parent always point to the same instance. For example, given the following entity classes
public class Order
{
public int OrderId{get;set;}
public EntityCollection<LineItem> Items{get;}
}
public class LineItem
{
public Order Order{ get;se...
I am having some problems with a few queries using Linq to NHibernate. These queries are fairly simple for me to do in SQL but for some reason I am having problems with Linq
For example if I want to find all entities which have any of a list of tags attached like this (I have greatly simplified the code for this message):
public class ...
Hi!
I'd like to create an application using ASP.NET MVC, that should run under mono 2.4 (compiling will be done on a Windows box). Has anyone getting luck with this? Here is what I've already tried:
ASP.NET MVC on mono without any persistence model support, and using nhaml as the view engine
S#aml architecture, which is a quite good f...
I use custom developed ORM currently and am planing to move to nhibernate.
Currently, I use both L1 - session level caching and L2 - Application level caching.
Whenever an object is requested from L2 cache by L1 cache, it checks database for modified since last load, and loads only if it has been modified.
Can I do this with NHibernat...
Hello there,
I am trying to use NHibernate with Spring.Net und mySQL 5. However, when setting up the connection and creating the SessionFactoryObject, I get this InvalidCastException:
NHibernate seems to cast MySql.Data.MySqlClient.MySqlConnection to System.Data.Common.DbConnection which causes the exception.
System.InvalidCastExcept...
There are two tables Person and Address. I have a mapping table PersonAddressMap which contains an additional column IsCurrent other than the two foreign keys (no explicit primary key column). I have created three mapping classes one each for Person, Address and PersonAddressMap. I need to access all the Addresses of a Person and also ac...
I am trying to build the following association in NHibernate (the base Entity class contains an Id property, it and the attributes are from S#arp Architecture)
public class Terminal : Entity {
public virtual string Name { get; set; }
}
public class Order : Entity {
[NotNull]
public virtual Terminal Terminal { get; set; }
}
...