Page 1 of 1
Have a attribute point to a string object and not be a actual string
Posted: Thu 17 Jul 2014 19:21
by ashlar64
Hello,
I have a entity class that has attributes for all it's properties. I am using the CategorAttribute(String) attribute. The problem I am having is that in the Constructor parameter only let's me put a literal string in. I want to be able to pass it a const string from my class.
The code behind looks like:
Code: Select all
[Column(Storage = "_SyTy", CanBeNull = false, DbType = "integer NOT NULL", UpdateCheck = UpdateCheck.Never)]
[System.ComponentModel.Category(@"_teleTrans")]
public int SyTy
I would like it to be changed to:
Code: Select all
[System.ComponentModel.Category(_teleTrans)]
Is there a way to do this?
Re: Have a attribute point to a string object and not be a actual string
Posted: Fri 18 Jul 2014 12:14
by MariiaI
In fact, this is not a LinqConnect provider-specific question. The CategoryAttribute Class comes from the System.dll assembly ( System.ComponentModel namespace) and specifies the name of the category in which to group the property or event when displayed in a PropertyGrid control set to Categorized mode. Please refer to:
http://msdn.microsoft.com/en-us/library ... .110).aspx
http://stackoverflow.com/questions/1555 ... ibute-name
Re: Have a attribute point to a string object and not be a actual string
Posted: Fri 18 Jul 2014 13:22
by ashlar64
I can do this manually.
For instance
public class Test
{
private const string _teleTrans = "string Attrbitue";
[System.ComponentModel.Category(_teleTrans)]
public int TestInt {get; set;}
}
But when you open the Attributes dialog box from clicking on the Attributes in the property grid...it does not allow you to point to a string. It will only let you put actual text in. So in other words I want the designer.cs file not to put quotes around the word _teleTrans.
Re: Have a attribute point to a string object and not be a actual string
Posted: Thu 24 Jul 2014 15:14
by Shalex
Thank you for your suggestion. We will investigate the possibility of implementing this functionality and notify you about the result.
Re: Have a attribute point to a string object and not be a actual string
Posted: Thu 31 Jul 2014 14:48
by Shalex
The new (4.4.553) build is available for download. Starting from this version, LinqConnect allows setting constant via interface of the Attributes window. For this, please use the ConstFieldName= prefix.
E.g.: ConstFieldName=_teleTrans .
The result would be: [System.ComponentModel.Category(_teleTrans)] .
Re: Have a attribute point to a string object and not be a actual string
Posted: Tue 02 Sep 2014 14:41
by ashlar64
That is great that you added this! I was thinking I might have to add a really ugly work around that would require alot of redundant code but this will make that unnecessary. Thank you very much!
Re: Have a attribute point to a string object and not be a actual string
Posted: Wed 03 Sep 2014 08:02
by MariiaI
If you have any further questions regarding working with LinqConnect, feel free to contact us.