Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Custom Attribute Alternatives
    primarykey
    data
    text
    <p>Currently, I've created a class with ~30 properties to be set. This is done to build up a URL request later on(ie, "<a href="http://www.domain.com/test.htm?var1=a&amp;var2=b...&amp;var30=dd" rel="nofollow noreferrer">http://www.domain.com/test.htm?var1=a&amp;var2=b...&amp;var30=dd</a>").</p> <p>The issue I'm facing is the property names don't necessarily match the query variable names(this is intended to be different). For example, I may have a variable titled "BillAddress", whereas the query variable will need to be "as_billaddress".</p> <p>I have no control over the query variable naming scheme as these are set at an external source.</p> <p>One possible solution I've used is creating a custom attribute and decorating the properties with their respective query counterparts:</p> <pre><code>[CustomQueryAttribute("as_billaddress")] string BillAddress{get;set;} </code></pre> <p>To retrieve the attribute though, requires a little reflection and due to the larger number of properties, I was curious if there is a neater way to accomplish this functionality. Not so much as setting/retrieving custom attributes without reflection, but being able to tie an alternate string variable to any property.</p> <p>I've also pondered about setting each variable up as a sort of KeyValuePair, with each key representing the query counterpart, but I didn't get too far in that thought.</p> <p>To summarize/clarify my above backstory, what would you do to associate a string with a property(not the value of the property)?</p> <p>As always, any comments are greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload