I don't just want the underlying sql string; I want a fully populated
IDbCommand (i.e. its Parameters collection filled) based on the parameter
object that I pass in. IPreparedCommand is a contract for inspecting a
<statement /> node and applying the parameter object with the intent of
executing the query inside ibatis and eventually mapping the output. The
functonality I've added allows someone to go half-way through that process: I
just want the <statement /> and parameter object processed. I'll choose whether
or not I want to execute the query or pass it to another execution engine.
IPreparedCommand requires you to pass in a request scope that is typically used
during the normal map/execute/map lifecycle. My CreateCommand creates the
appropriate request scope internally and stops processing when it has a
complete IDbCommand. This workflow isn't really a standard ibatis workflow so I
didn't make it part of the interface; you have to call
DefaultPreparedCommand.CreateCommand yourself.
It can also help with testing the parameter object mapping without actually
having to execute the query on the database:
<select id="FindProduct">
SELECT * FROM Product WHERE ProductId = #value#
</select>
var preparedCommand = new DefaultPreparedCommand();
var findProductStatement = modelStore.GetMappedStatement("FindProduct");
IDbCommand command = preparedCommand.CreateCommand(findProductStatement, 42);
Assert.AreEqual(command.Parameters["@param0"].Value, 42);
________________________________
From: Sal Bass <[email protected]>
To: [email protected]
Sent: Sunday, May 31, 2009 9:59:25 AM
Subject: RE: Ibatis.Net - A Call to Arms
Ron,
I am still trying to dig my way through all of the Ibatis source to get
familiar with how everything works. Is the purpose of your code to get access
at the sql statement that is in the mapping file before it is executed?
________________________________
Date: Sun, 31 May 2009 00:03:40 -0700
From: [email protected]
Subject: Re: Ibatis.Net - A Call to Arms
To: [email protected]
I've implemented one of my suggestions:
var preparedCommand = new DefaultPreparedCommand();
var findProductStatement = modelStore.GetMappedStatement("FindProduct");
IDbCommand command = preparedCommand.CreateCommand(findProductStatement, 42);
That should allow us to write some tests against the dynamic sql generator
without having to execute a query on a real database.
________________________________
From: Ron Grabowski <[email protected]>
To: [email protected]
Sent: Thursday, May 28, 2009 12:50:18 AM
Subject: Re: Ibatis.Net - A Call to Arms
I'm still alive and forcing my team to use IBatis.Net :-)
They've commented on the verboseness and requirement of having multiple xml
config files...things like not being able to use one of the built-in
DbProviderFactorys strings.
Perhaps merging providers.config within sqlmap.config so there are less files.
Fluent interfaces seem to be the new hotness these days. Improve the abilitty
to configure the mapper without sqlmap.config and providers.config.
Migrate the internal Transaction objects to System.Transaction.
Expand on the demos of using Castle NVelocity to do the dynamic sql ???
Have a way to generate an IDbCommand without actually executing it:
//
https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/commons/Rhino.Commons/ToPublic/SqlCommandSet.cs
var sqlCommandSet = new SqlCommandSet();
// lots and lots of products
foreach (Product product in products)
{
sqlCommandSet.Append(dataMapper.CreateCommand("Product.Insert", product));
}
// one trip to the database when using ADO.Net 2.0 and Sql Server
sqlCommandSet.ExecuteNonQuery();
________________________________
From: Sal Bass <[email protected]>
To: [email protected]
Sent: Monday, May 25, 2009 5:07:34 PM
Subject: Ibatis.Net - A Call to Arms
Per Clinton's suggestion, I am making this post to find out if we can keep
Ibatis.Net going. As we all know, Ibatis fills an important niche and is still
very relevant. We need people to take charge and to commit time for
development. So, who's in? If we don't do this there is nothing to keep it
going.
________________________________
HotmailĀ® has a new way to see what's up with your friends. Check it out.
________________________________
HotmailĀ® has a new way to see what's up with your friends. Check it out.