Not sure if this is correct, I've used this

Property(x => x.Age,
map =>
{
map.Generated(PropertyGeneration.Never);
});


And my entity property is this

public virtual Int32? Age
{
get
{
if (!DateOfBirth.HasValue) return null;

var now = DateTime.Now;

Int32 age = now.Year - DateOfBirth.Value.Year;

if (now.Month < DateOfBirth.Value.Month)
return age;
if (now.Month > DateOfBirth.Value.Month)
return age--;
if (now.Day < DateOfBirth.Value.Day)
return age--;

return age;
}

set { }
}

This allows you to query on the property

var people = from a in _personRepository.FindAll()
where a.Age > 10
select new PersonViewModel
{
Id = a.Id,
FirstName = a.FirstName,
LastName = a.LastName,
Age = a.Age ?? 0,
City = a.Address.City
};


On , "Mauro D." <[email protected]> wrote:
I'm using this code for mapping entities:



var inspector = (IModelInspector)new SimpleModelInspector();

ModelMapper mapper = new ModelMapper(inspector);

mapper.Class(m =>

{

m.Id(x => x.Id, g => g.Generator(Generators.Native));

m.Table("Entities");

m.Version(x => x.Version, map =>

{ map.Column("NHVersion"); });

m.Property(x => x.Data, map =>

map.Type());

});



I want to be able to exclude a single property from the mapping.

There's a simple method with this mapping usage or I have to change

style and create my personal inspector inheriting from a base one?



Thanks



--

You received this message because you are subscribed to the Google Groups "nhusers" group.

To post to this group, send email to [email protected].

To unsubscribe from this group, send email to [email protected].

For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.




--
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to