Like I said, I'm new to iBatisNet. :-) I'm aware of mock objects but
have never used them. This just seemed the "correct" approach; hiding
the iBatis stuff in places that it made sense.
BTW, I did get it to work as follows:
// public constructor for Company accepting string as key
Public Company(string CID)
{
ISqlMapper mapper = MYLib.Mapper.Instance();
mapper.QueryforObject("selectCompany", CID, this);
}
Works just like I wanted.
Thanx,
Garth
Arjen Smits wrote:
What u want to do is not possible with C#, like u said u will need to
create an temporal instance and then assign the fields using the
temporal object.
However, why would u want to do this in the constructor? It seems abit
like a bad idea to me. Because basically you are robbing yourself of the
ability to create mock objects.. using that constructor that is..
Delegating the creation of your objects to other classes (which
instantiate and initialise the object) seems like a much more sensible
solution.
So I am curious as to why you would want an solution as this :)
Arjen
ProPlanet BV
Rijnstraat 495F
5215 EJ 's-Hertogenbosch
The Netherlands
Tel +31 (0)73 513 0637
Fax +31 (0)73 631 2114
www.proplanet.eu
Disclaimer
This e-mail and any attachment(s) sent with it are intended exclusively for
the addressee(s), and may not be used by, opened by, passed on to, or made
available for use to, any person other than the addressee(s). ProPlanet rules
out any and all liabilities resulting from any electronic transmission.
-----Oorspronkelijk bericht-----
Van: Garth Keesler [mailto:[EMAIL PROTECTED]
Verzonden: woensdag 21 februari 2007 11:13
Aan: iBatis Net
Onderwerp: Using QueryforObject in Constructor
Brand new to iBatis C#. I'd like to use the QueryforObject method within
the constructor method for each class so the iBatis logic is contained
within the standard approach to instantiating objects in C#. Prob is, a
constructor already has the object created. Is it necessary to create a
temporary instance using QfO and then to assign the fields from it to
the constructor-created instance? I must be missing something really
simple.
Thanx,
Garth
.