I have a many-to-one relationship between objects Product and Supplier. I need to be able to delete Supplier without deleting the Products that belong to it.
Here is a simplified version of classes:
public class Supplier {
public virtual IList<Product> Products { get; protected set; }
}
public class Product {
// Product belong...
Hello,
I'm trying to implement class inheritance hieararchy with NHibernate and SQL server. I made it work fine with the table per hierarchy strategy (one table and several subclass elements in the mapping file).
However the table per subclass strategy (N + 1 tables and N joined-subclass elements in one mapping file) makes more sense i...
Please forgive the clumsy question (if you can figure out a better way to word the question feel free to edit away).
I have two classes SupportTicketCategory and SupportTicket (respectively):
public class SupportTicketCategory
{
public SupportTicketCategory()
{ }
private int _supportTicketCategoryID;
public virtual ...
In this question I was answered hot to map a composed entity from the primary key of the table.
So given:
public UserMap()
{
WithTable("aspnet_Users");
Id(x => x.Id, "UserId")
.GeneratedBy.Guid();
Map(x => x.Name, "UserName");
Map(x => x.Login, "LoweredUserName");
WithTable("LdapUsers", m => {
m.Map...
We have a legacy db that I am mapping to NHibernate. We have some calls that accept a Predicate object that generates a where clause for a table/view entity. We were able to modify the Predicate to return Criterion and use it with the table entity. This method does not work with the view entities, because the mappings return an error ...
Hello All
I'd like to have an 'UnassignedDepartment' object instead of letting employees have a null Department:
public class UnassignedDepartment : Department
{
public UnassignedDepartment() : base("not yet assigned") {
Id = -99; <-- just some Id that can be held constant, not be generated..
}
}
This is accessible by...
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...
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?
...
Essentially the title of this question explains the essense of what I am trying to do, but to create a contrived example...
I have a class, call it Employee. Employee has an IPaymentBehaviour...
public class Employee
{
IPaymentBehaviour _paymentBehaviour;
protected internal Employee() { /* required by NH */}
public Employee(IP...
So I'm trying to update an object in my MS SQL 2005 database using NHibernate. Please keep in mind that this is a legacy database used in many live systems and I can't remove the triggers.
When my data provider tries to .SaveOrUpdate() a row I get two returns (one for the actual update, and one when the trigger executes)
The raw retur...
Hi All
NHibernate noob here. Looking for advice on how to map the following common scenario:
[Store]
id pk
Name
[StockItem]
id pk
Name
[StockItemStore]
id pk
StockItemId fk
StoreId fk
ParLevel
I have created a domainmodel that allows various StockItems to be assigned to various Stores via the StockItem Entity using a AssignToStore(S...
How to create a Multi-Column Index and/or Unique Constraint using NHibernate Mapping or Fluent NHibernate.
...
I have a named Query that uses a view. I am unable to create a class mapping because this view does not have a Id column. I created a named query and set it to return it as a class, defining all the return values. However, I still receive a KeyNotFound Exception. If I set all of the columns to It returns the List. How can you tell...
I have a library with a class called Recipient which has it's own fluent mapping setup within the library.
Now in another project I have created a new class called SentEmail which inherits from Recipient, I want to be able to create a new mapping class file based on the original Recipient map. If I could update the original ClassMap fi...
Hi,
I have been whipped into submission and have started learning Fluent NHibernate (no previous NHibernate experience). In my project, I am programming to interfaces to reduce coupling etc. That means pretty much "everything" refers to the interface instead of the concrete type (IMessage instead of Message). The thought behind this is ...
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 th...
I'm trying to create a mapping similar to the following with fluent nhibernate:
<class name="IAccountManager"
abstract="true"
table="IAccountManager">
<id name="Id">
<generator class="hilo"/>
</id>
<union-subclass
table="DefaultAccountManager"
name="DefaultAccountManager">
...
Is there any way to find out if a property is mapped to a field.
I would like this to generate something like a "generic like search":
string[] words.
words = search.Split(' ');
Type type = typeof(T);
Disjunction disjunction = new Disjunction();
foreach (System.Reflection.PropertyInfo property in type.GetProperties(...
Working on a website that has Employee and Branch entities, using a database table "Employees" which also contains the branch id and branch name. I can't change the client's database so I need to map Employees and Branches from the same table.
I guess I need some type of distinct clause in the mapping XML to get a distinct list or set o...
Within my Entity assembly I have a class:
public class MyClass : IAuditObject
{
// Implementation here
}
However the interface IAuditObject is defined in a separate Audit assembly.
How can I successfully generate mappings using:
NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(MappingFile,EntityAssembly);
where Ent...