473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Retrieve the property name - How To?

Imaginate you have one method that accept some arguments like:

1- a control
2- un Type
(MyType)
3- el nombre de una Propiedad "PropertyName"

Example:

.Add(Me.txtCustomerID, GetType(Customer), "CustomerID")

Inside this method, I use reflection tu scan all properties.

I want avoid to use literals like "CustomerID" to refer the properties. I
would wish another strong method to retrieve the Name of the property.

Any help will be appreciated

TIA
Antonio

Sep 26 '05 #1
3 1871
You mean that you need a method to reference a property without its
name ?

Sep 27 '05 #2
Antonio,

You are using reflection (late binding). With that it gets its information
at runtime. Why would you use this time consuming method, while you want in
fact strong typed names.

Just don't use late binding and don't even use collections.

Just my thought,

Cor
Sep 27 '05 #3

Hi,

Reflection is great and powerful... I think that time consuming it is not
perceivable in commercial applications.
There is a function GetType that allow me get the Name of a type as string.
Ex:
Dim TypeName as String = GetType(MyType).Name --> return
"MyType"
what I am trying to do, but I not sure that is possible, is something like
this.
Dim PropertyName as String = GetMemberInfo(MyType.MyProperty).Name --->
return "MyProperty"
Properties on my busines objects contains custom attributes.
Ex:

<Serializable(), Entity(TableStorage:="ANALISIS", Description:="Analisis")>
_
Public Class Analisis : Inherits BusinessBase

.....

<Entity(DataField:="ANA_PUNTO_INGRESO", Key:=1, IsRequired:=True)> _
Public Property PuntoIngreso() As Integer
Get
Return mPuntoIngreso
End Get
Set(ByVal Value As Integer)
mPuntoIngreso = Value
End Set
End Property
End Class

I want to be able to retrieve DataField attrib of any property without using
the property name as string. For this reason I need a function that does
this for me.

Antonio
"Cor Ligthert [MVP]" <no************@planet.nl> escribió en el mensaje
news:eZ**************@TK2MSFTNGP09.phx.gbl...
Antonio,

You are using reflection (late binding). With that it gets its information
at runtime. Why would you use this time consuming method, while you want
in fact strong typed names.

Just don't use late binding and don't even use collections.

Just my thought,

Cor

Sep 27 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Antonio Paglia | last post by:
Imaginate you have one method that accept some arguments like: 1- a control 2- un Type (MyType) 3- el nombre de una Propiedad "PropertyName" Example: ...
9
by: Don | last post by:
Say I have a class like so: Public Class MyClass Public Prop1 as Integer Public Prop2 As Integer Public Prop3 As Integer End Class Is it possible to retrieve a list of the variables or...
6
by: Allen | last post by:
Hi, I want to retrieve the selected folder and entered file name from the SaveFilsDialog. The user is able to create or selected a different folder during the dialog displayed. If user enters...
1
by: tomjbr.32022025 | last post by:
I have started looking at the nhibernate framework, but do not really like the string based API which makes it impossible to use automatic refactoring of a property name without the risk of getting...
5
by: Ken | last post by:
I'm trying to run a loop to capture column property information from a table in my datasource. Can anybody see where this is going wrong? Dim tbl As New DataTable Dim col As DataColumn Dim x...
1
by: Mel | last post by:
Anyone know how I would retrieve the MaxLength property of a column in my Access Database table? I know how to retrieve table data, for example the "Quote #" field in my example code below, but I...
2
by: kjqua | last post by:
Hi, I build a control with method and property, and one specific method. The InitLayout() see below. protected override void InitLayout() { // base.InitLayout(); if (DesignMode) { // I'm...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
9
by: gavy7210 | last post by:
hello friends i am new to struts. i want to add the user information in the database and then display it back to him. i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.