Reputation: 7
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.
Upvotes: 0
Views: 403
Reputation: 321
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;}
}
Upvotes: 1