0

I met a question about NHibernate mapping.

Currently I have one object Person below.

class Person{
   public string FirstName{get; set;}
   public string LastName{get; set;}
   public string Age{get; set;}
   public string Sex{get; set;}
   public string Las{get; set;}
}

And in C# code I have THREE class libraries, one of them is used for sharing class library.

The other two: assemblyA and assemblyB

In assemblyA: I want to mapping Person and only use the FirstName and LastName property, so we have one mapping file in assemblyA

In assemblyB: I want to mapping Hole fields.

So when the application run, I can use different mapping files to mapping object then can fetch correct data in different repository.

My question is: Can I use multiple different mapping files for one object? just want to avoid some unnecessary mapping.

Linqtoxml
  • 7
  • 4

1 Answers1

1

Why not use two classes? Note this does not mean you need to have two tables. PersonName can be a component of Person I believe. You would have two mapping classes for this.

class PersonName{
   public string FirstName{get; set;}
   public string LastName{get; set;}
}

class Person{
   public PersonName Name{get; set;}
   public string Age{get; set;}
   public string Sex{get; set;}
   public string Las{get; set;}
}
user2586804
  • 321
  • 1
  • 10
  • thanks for your reply. Firstly I try to use this way, but when the two class use the same property. the mapping files does not work. Just want to use different mapping to control the object. :) – Linqtoxml Sep 06 '13 at 02:02