Prev: window based authentication with members defined in a distribution list.
Next: Seconds from DB to hh:mm:ss in GridView. How to?
From: J on 19 Feb 2010 09:43 I'm trying to decipher some code like the following: <MaxLength(50)> _ <SQLParameter()> _ <PropertyDBType(SqlDbType.VarChar)> _ Public Property Coolness() As String Get Return ModifiedDataValues("Coolness").Value End Get Set(ByVal value As String) ModifiedDataValues("Coolness").Value = value End Set End Property What are the first 3 lines telling me? Some sort of binding sql server properties to a class property? What purpose and what would this be used for? Whats the c# equivalent syntax for those 3 lines? Where can I see an example online? Thanks.
From: Scott M. on 19 Feb 2010 10:06 "J" <nobody(a)nowhere.com> wrote in message news:_uKdnWei06kAPuPWnZ2dnUVZ_uidnZ2d(a)posted.nuvoxcommunications... > I'm trying to decipher some code like the following: > > <MaxLength(50)> _ > <SQLParameter()> _ > <PropertyDBType(SqlDbType.VarChar)> _ > Public Property Coolness() As String > Get > Return ModifiedDataValues("Coolness").Value > End Get > > Set(ByVal value As String) > ModifiedDataValues("Coolness").Value = value > End Set > End Property > > What are the first 3 lines telling me? Some sort of binding sql server > properties to a class property? What purpose and what would this be used > for? Whats the c# equivalent syntax for those 3 lines? Where can I see > an example online? > > Thanks. The first 3 lines are compiler attributes. They are instructions for the compiler that help it modify the code that follows. The first line indicates taht the SQL parameter cannot be longer than 50 characters. The second line indicates that the property maps to a SQL Parameter object. The third line indicates that the data type for the parameter is SQL VarChar. In C#, the syntax is largely the same, but uses square brackets [] to denote the compiler attributes. This is also referred to as "decorating" the code and it is used/can be used on a wide variety of code structures. -Scott
From: Alexey Smirnov on 19 Feb 2010 10:19
On Feb 19, 3:43 pm, "J" <nob...(a)nowhere.com> wrote: > I'm trying to decipher some code like the following: > > <MaxLength(50)> _ > <SQLParameter()> _ > <PropertyDBType(SqlDbType.VarChar)> _ > Public Property Coolness() As String > Get > Return ModifiedDataValues("Coolness").Value > End Get > > Set(ByVal value As String) > ModifiedDataValues("Coolness").Value = value > End Set > End Property > > What are the first 3 lines telling me? Some sort of binding sql server > properties to a class property? What purpose and what would this be used > for? Whats the c# equivalent syntax for those 3 lines? Where can I see an > example online? > > Thanks. These are attributes to get information about property at runtime. For more information please look at MSDN vb: http://msdn.microsoft.com/en-us/library/aa711860.aspx c#: http://msdn.microsoft.com/en-us/library/aa287992.aspx |