nhibernate-mapping

“extend” an xml schema

北慕城南 提交于 2020-01-04 06:01:16
问题 I'm trying to "extend" an xml schema (nhibernate here, for example), to add my own entities inside of it. I'm stuck to the point where validation chokes on the "exm:foo" (and exm:foobar) entity, as the "base" schema doesn't allow it. How can I manage to do that, without changing the base schema ? Sample : <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Test" namespace="Test.DataAccess.Entities" xmlns:exm="urn:extend-mappings"> <class

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

人走茶凉 提交于 2020-01-04 05:54:46
问题 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 other way around. Is there any way to do this? I'm perfectly fine with a multi-stage process, I just want to know what other people have done that was successful

NHibernate ignores length attribute

99封情书 提交于 2020-01-04 04:04:10
问题 After running SQL Profiler, I realized that NHibernate was mapping strings to nvarchar(4000). I fixed it by specifying type=AnsiString and length=... in the hbm file. It is now generating varchar(8000) statements, and it is ignoring the length. How come?! hbm file: <property name="EmailAddress" column="EMAIL_ADDRESS" type="AnsiString" length="120" /> database field: [EMAIL_ADDRESS] [varchar](120) NULL, TIA 回答1: Actually in previous versions of nhibernate the check against length was

Receiving Index Out of Range with NHibernate

孤人 提交于 2020-01-03 10:44:19
问题 I'm hoping that someone can help me with this issue. I've been racking my brain and my project is due very soon. Thank You in advance. I'm receiving an index out of range exception when inserting a new record. After searching endlessly for information, it was suggested that the number of column values in my mapping do not match that in my persistent class. However, I counted and re-counted, and they seem to match. As you can see by my code below, I'm using NHibernate.Mapping.Attributes to do

How can I map to a joined subclass with a different column than the id of parent?

别来无恙 提交于 2020-01-03 09:14:23
问题 I am working with a brownfield database and am trying to configure a subclass map which joins to its subclasses with a column other than that of the specified id. The login table has a primary key column login_sk which I'd like to use as its id. It joins to two tables via a login_cust_id column (to make things more fun the corresponding columns in the adjoining tables are named differently). If I setup login_cust_id as the id of the UserMap it joins to its subclasses as expected. For what I

NHibernate Mapping for User Roles and Privileges

落花浮王杯 提交于 2020-01-03 03:57:10
问题 The Scenario I've been banging my head against the wall trying to figure out the correct mapping for 3 entities: User, Role, and Privilege. In my application, Users can have Privileges, which just give a user additional permissions. Users can also have Roles which are essentially privileges that require additional properties. For instance, a user might have a role of "Application Administrator" in which case the ApplicationAdministratorRole.cs would need a property to contain the list of

NHibernate exception: could not initialize a collection, Invalid column name. Fluent mapping. Maybe a many-to-one issue?

妖精的绣舞 提交于 2020-01-02 06:25:30
问题 I am puzzled and frustrated by an exception I'm getting via NHibernate. I apologize for the length of this post, but I've tried to include an appropriate level of detail to explain the issue well enough to get some help! Here's the facts: I have a Person class which contains a property BillingManager , which is also a Person type. I map this as an FNH "Reference". I have an ExpenseReport class which contains a property SubmittedBy , which is a Person type. I map this as an FNH "Reference". I

nHibernate, mapping two properties to the same class

让人想犯罪 __ 提交于 2020-01-02 06:07:22
问题 I have a Mailclass, where I want to save both the sender and the recipient as a reference to the User class; public class dbMail : Entity { public virtual int ThreadID { get; set; } public virtual dbUser From { get; set; } public virtual dbUser To { get; set; } public virtual DateTime MailDate { get; set; } public virtual string MailText { get; set; } public virtual bool IsRead { get; set; } } and the mapping: <id name="ID"> <generator class="identity" /> </id> <property name="ThreadID" />

nHibernate, mapping two properties to the same class

[亡魂溺海] 提交于 2020-01-02 06:07:11
问题 I have a Mailclass, where I want to save both the sender and the recipient as a reference to the User class; public class dbMail : Entity { public virtual int ThreadID { get; set; } public virtual dbUser From { get; set; } public virtual dbUser To { get; set; } public virtual DateTime MailDate { get; set; } public virtual string MailText { get; set; } public virtual bool IsRead { get; set; } } and the mapping: <id name="ID"> <generator class="identity" /> </id> <property name="ThreadID" />

Fluent nhibernate: How do I map an entity with a property who's type is an interface?

て烟熏妆下的殇ゞ 提交于 2020-01-01 06:49:09
问题 I have an entity like: public class Employee { public int ID { get; set; } public IAccountManager AccountManager { get; set; } ... } I also have a mapping defined for "DefaultAccountManager" - a concrete implementation of IAccountManager. When mapping the above "Employee" entity, how do I tell NHibernate to persist/load the AccountManager property using the mapping defined in "DefaultAccountManager"? Edit: Actually if I could setup a mapping for IAccountManager so that NHibernate could just