I want to generate aliases for properties in 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 any other way to define an alias in C#. The Purchase class was generated by Linq-to-SQL
No, it’s not possible to do in C#. Property name is single identifier you can define for it.
Don’t know if this is what you’re searching for or not:
but you can define (say) a
Dictionary<string,object>whereKeyis a propertyname andvalueis a value of the property. In this way you can define dynamic property cash, with changing property names and values at runtime.or can use an ExpandoObject , if you use
C# 4.0