Reputation: 183
Is it possible to map a class in model to a table that has more columns than the model class? I just want to map specific columns of a table using Fluent Nhibernate
. For example the table has these columns:
ProductId
ProductName
BatchNumber
StoreId
but in the model class I just want: ProductId
, ProductName
.
Is it possible not to include BatchNumber
and StoreId
in the model class?
Upvotes: 0
Views: 1226
Reputation: 1711
You can override mapping:
public class ProductAutoMappingOverride : IAutoMappingOverride<Product> {
public void Override(AutoMapping<Product> mapping) {
mapping.Id(p => p.ProductId),
mapping.Map(p => p.ProductName),
mapping.IgnoreProperty(p => p.BatchNumber);
mapping.IgnoreProperty(p => p.StoreId);
}
}
Upvotes: 5