Have a attribute point to a string object and not be a actual string

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Have a attribute point to a string object and not be a actual string

Post by ashlar64 » Thu 17 Jul 2014 19:21

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?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Have a attribute point to a string object and not be a actual string

Post by MariiaI » Fri 18 Jul 2014 12:14

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

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Have a attribute point to a string object and not be a actual string

Post by ashlar64 » Fri 18 Jul 2014 13:22

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Have a attribute point to a string object and not be a actual string

Post by Shalex » Thu 24 Jul 2014 15:14

Thank you for your suggestion. We will investigate the possibility of implementing this functionality and notify you about the result.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Have a attribute point to a string object and not be a actual string

Post by Shalex » Thu 31 Jul 2014 14:48

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)] .

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Have a attribute point to a string object and not be a actual string

Post by ashlar64 » Tue 02 Sep 2014 14:41

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!

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Have a attribute point to a string object and not be a actual string

Post by MariiaI » Wed 03 Sep 2014 08:02

If you have any further questions regarding working with LinqConnect, feel free to contact us.

Post Reply