Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:50:35+00:00 2026-05-26T16:50:35+00:00

I want to use map mechanism, based on property attribute marking, like this: [AttributeUsage(AttributeTargets.Property

  • 0

I want to use map mechanism, based on property attribute marking, like this:

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class DomainSignatureAttribute : Attribute { }

public class SomeThing {
    [DomainSignature]
    public virtual string SomePropertyForMapping {get;set;}
    [DomainSignature]
    public virtual int OtherPropertyForMapping {get;set;}

    public virtual string OtherPropertyWithoutMapping {get;}
}

So in ClassMap children I want to realise this method, that map all properties, marked by DomainSignatureAttribute attribute:

protected void MapPropertiesWithStandartType()
{
    foreach (PropertyInfo property in typeof(T).GetProperties())
    {
        if (property != null)
        {
            object[] domainAttrs = property.GetCustomAttributes(typeof (DomainSignatureAttribute), true);

            if (domainAttrs.Length > 0)
                Map(x => property.GetValue(x, null));
        }
    }
}

But there is a small problem with Linq. When FluentNHibernate builds mapping (Cfg.BuildSessionFactory()) it break with

Tried to add property ‘GetValue’ when already added.

exception. As I undestand I need to rebuild Linq expression: x => property.GetValue(x, null) into correct form.

Please don’t suggest to use AutoMap feature and don’t suggest to use manual mapping.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:50:35+00:00Added an answer on May 26, 2026 at 4:50 pm
    var domainproperties = typeof(T).GetProperties()
        .Where(prop => prop.GetCustomAttributes(typeof (DomainSignatureAttribute), true).Length > 0);
    
    foreach (var property in domainproperties)
    {
        Map(Reveal.Member<T>(property.Name));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For instance, if I want to map property Title I use: > Map(x =>
I am new to the structure map but i want to use it in
I want to place markers on the map. I want to use the standard
I want to use google map API for my desktop application. The application will
i want to use the gps in google map to automatically locate the user
I want to use a pair from STL as a key of a map.
I have a high-resolution image that I want to use as a tiled map
I want to use svcutil to map multiple wsdl namespace to clr namespace when
I'm using jQuery's thickbox and want to use it for a Google map link(s).
If one want to use the google map api and its map data,he should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.