How to define an alias for a property

I want to generate aliases for properties in the generated code. All I could do so far was:

partial class Purchase
{
    public User Customer
    {
        get
        {
            return this.User;
        }

        set
        {
            this.User = value;
        }
    }
}

I wonder if there is another way to define an alias in C #. The class Purchasewas generated by Linq-to-SQL

+5
source share
2 answers

No, this cannot be done in C #. A property name is one identifier that you can define for it.

Not sure what you are looking for or not:

but you can define (say) a Dictionary<string,object>, where Keyis the name of the property, and valueis the value of the property. This way you can define dynamic cash properties, with changing property names and values โ€‹โ€‹at run time.

ExpandoObject, C# 4.0

+2

, JSON newtonSoft,

 [JsonProperty("alias_name")]
 public type YourProperty {get;set;}

, , # JSON,

+1

All Articles