Domanda

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.

È stato utile?

Soluzione

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;}
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top