By Tim Dol - 10/2/2009
This may be a dumb question but I can't quite get this to work.
I have a string variable containing the fully qualified name of a business object.
Example: Dim var as String = "Avanti.DTS.BusinessObject.CustomersBO"
I want to instantiate the actual business object based on the string value so I can access the field names and lengths etc...
can someone let me know how to do this?
Thanks,
Tim
|
By Edhy Rijo - 10/2/2009
Hi Tim,
I believe you will need to use the Activator.CreateInstance() to make this work, something like this:
Dim var As String = "Avanti.DTS.BusinessObject.CustomersBO"
Dim myBO As Avanti.DTS.BusinessObject.CustomersBO
myBO = CType(Activator.CreateInstance(Type.GetType(var)), Avanti.DTS.BusinessObject.CustomersBO)
If you have a base BO class, then use it in the Dim myBO declaration.
|
By Charles R Hankey - 10/2/2009
I may be misunderstanding the question, but
dim newbo As MicroFour.StrataFrame.Business.BusinessLayer = New Myapp.Business.MyBO
works for me (assuming here myBO is in the myapp.business project)
Same thing works for me.myBO1 if you want the instance.
Need to use fill methods if you need data, but you can check field info etc without it.
Edhy's method, of course, is the solution when you are getting the BO name from a string, but I thought perhaps you weren't doing it dynamically in this case.
|
By Charles R Hankey - 10/2/2009
(and on rereading your question, Edhy understood your question better than I did.)
Darn I with there were a way to see the question while we are typing an anwer ... or is there ?
|
By Edhy Rijo - 10/2/2009
Charles R Hankey (10/02/2009) Darn I with there were a way to see the question while we are typing an anwer ... or is there ?
Yes there is, and I have been there before too .
While replying down at the bottom of the page there is header named "Last 10 Post in Descending Order" and on the right side there is a plus sign, just click the plus sign and you will see (guess what?) the last 10 post in descending order
|
By Charles R Hankey - 10/4/2009
Yes! I thought I remembered you asking exactly that question and getting an answer but could remember it. Very cool. Now if they could get Firefox to insert images ...
|
By Charles R Hankey - 10/4/2009
... and of course that should read "could NOT remember it, but there is also not ability to edit one's own posts ... is there?
|
By Edhy Rijo - 10/4/2009
Charles R Hankey (10/04/2009) ...but there is also not ability to edit one's own posts ... is there?
Nope, we all have one shot to make a good impression
|
By Charles R Hankey - 10/5/2009
So the moral of the story is "Do not drink and post."
|
By Trent L. Taylor - 10/5/2009
Nope, we all have one shot to make a good impression
But just think of it this way...it helps boost your forum count
We may have the ability to request this on a per individual basis at some point, but there are some obvious reasons that we prevent this as I am sure you have seen on other posts when we have discussed this before.
|