Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : Other Databases : WilsonXmlDbClient Example

Date Post
11/12/2004 3:20:37 PM Paul, is there an example how to configure and use WilsonXmlDbClient provider with ORMapper?

Thanks for info.
Dragan
11/13/2004 11:59:03 AM Hi Dragan:

Sorry its taken me so long to nearly get caught up after my move. The following code with configure the ORMapper to use the XmlDbClient:

Wilson.ORMapper.CustomProvider customProvider = new Wilson.ORMapper.CustomProvider(
"WilsonXmlDbClient", "Wilson.XmlDbClient.XmlDbConnection", "Wilson.XmlDbClient.XmlDbDataAdapter");
customProvider.StartDelimiter = "[";
customProvider.EndDelimiter = "]";
customProvider.IdentityQuery = "SELECT @@Identity;";
customProvider.SelectPageQuery = "SELECT * LIMIT {0} OFFSET {1}";

As far as examples go -- I don't have anything polished. It uses the dataset internally (the XmlDbClient, not the Mapper) and its a little forgiving on the format of your xml, but only to a point, so you may need to create the xml programmatically using the dataset the first time. This would especially be true if you want to have it strongly typed and using auto-increments, since those features do depend on the schema that the dataset uses.

Thanks, Paul Wilson
12/8/2004 10:06:21 PM Does anyone have a code sample of the Wilson ORMapper working with the WilsonXmlDbClient provider?

While I can get this combination to work to add new records to an XML data store, the same mapping file and engine will not retrieve any records.

I've been struggling with this for hours. I think I'm missing something that a sample will illustrate.

So, does anyone have a working sample?
12/9/2004 6:08:04 AM One of the main causes of no records being returned is a null field that doesn't have a nullValue mapping, or some other type incompatibility. For the XmlDbClient, if you create the initial xml file with a DataSet in code, including typing of all the columns, than you should be OK if you add necessary nullValue settings.

Thanks, Paul Wilson
1/26/2006 5:05:11 PM
Wow, I am _very_ surprised no one else is using these two things together much (I am making a big assumption based on the lack of posts in this forum as well as the lack of much info anywhere else), this is a great combo for the purposes of unit testing (even alone, WilsonXmlDbClient is good for that reason); writing unit tests against databases is generally a bad idea, but writing against xml data isn't so bad.

Paul, I am having an issue getting these things to work together well, and I am hoping it is merely because of my data - you mention the schema being important; because of my use of code generators and such, it has literally been years since I have had much to do with DataSets directly and in trying to create a basic set of XML data from my database, I basically pull the data into a DataSet via WORM's GetDataSet(string sql) method and then call an overload of WriteXml() to get the file (I call one that allows me to indicate whether it should include the schema, if my memory is serving me correctly).

The xml file works great for retrievals, but when I try to persist a new entity that is tied to a database table that normally uses an identity column, I am getting an exception.

Any ideas on just what I should do to get clean DataSet xml out of my database?

Thanks,
Jason Bunting

1/27/2006 3:35:00 AM Hi Jason:

I do think the XmlDbClient is cool, but I've never actually used it myself. I was mostly just having fun and giving something that some had asked for. I know a few that have used it, but my hope for someone to take and extend it has not came to fruition. So it really still needs some better sql parsing, and some additions like Create Table.

Anyhow, how do you make it use an identity? The trick to discovering the necessary schema is to do it all with a dataset first. And a DataColumn has an AutoIncrement property that you can set to true! Setting it results in this line in the xml schema:

<xs:element name="MyColumn" msdata:AutoIncrement="true" type="xs:int" minOccurs="0" />

I believe that was all that was necessary.

Thanks, Paul Wilson
1/27/2006 9:37:15 AM Hey Paul, thanks for your reply. I spent more time on this yesterday and found out about the attributes you mention.

My original problem was persisting an object using the WilsonXmlDbClient with WORM. I kept getting an error: "XmlDbParameter: Parameter Direction must be Input".

This is thrown by the setter portion of the Direction property of the XmlDbParameter class, called by GetParameter(IDbCommand command, Parameter parameter) (line 346 in my copy of WORM's Internals/Connection.cs file).

Why is this property on the XmlDbParameter class throwing an exception? The mapper code is going to try to set this property each time, from what I can tell, which means each time this exception is thrown. If I comment that out, the object persists to the xml file just fine, but I don't know yet what ramifications this has.

Any help is appreciated. Again, using this with WORM is a killer combo for unit testing and I would love to help get it to a better place, I just don't know much about this tool yet.

Thanks Paul!

Jason

was being called by
1/27/2006 11:38:44 AM The ORMapper has changed some since the XmlDbClient was released -- so they may simply be out of sync a little. So if you've got it working with that change, then that probably is the correct thing to do here. Maybe someday I'll take a look at the XmlDbClient again, but my intent really was just to give it to the community -- its not something I use myself (not that it can't be used). Maybe you'd like to take over the project and drive it so that it improves and grows. :)

Thanks, Paul Wilson
1/27/2006 12:43:09 PM
Well, I may tinker a bit more with it; I really want it to work well enough to use with the basic WORM functionality because I would like to include an aspect of it in the CodeSmith templates that I am continually working to improve.

Although unit testing and test-driven development are still not as widely used as I hope they one day will be, I use them and like the idea of being able to have unit tests work against xml data when my WORM-utilizing applications run through their tests.

"Maybe you'd like to take over the project and drive it so that it improves and grows."

It is possible, though my use for it is definitely limited to using it for unit testing my WORM applications; inasmuch as I will change it to that end, I will work on it. I will probably start posting my 'version' of it to the same place as the CodeSmith templates once I feel good about where it is at.

Thanks for replying,
Jason

1/27/2006 1:14:15 PM Hey Jason:

I understand -- just to be clear though:

If you do have the desire, I will gladly make you an Admin on the project at GotDotNet, or you can take it and grow it as you see fit somewhere else (your site, another GotDotNet project, SourceForge, etc.). I'll also gladly point people to whatever destination you would like as the official new home. Whatever you want -- as much or as little. It really is a cool little library, and it does deserve a little more. I've been bummed about it since several people asked for it and promised to work with it, but they all kind of disappeared when they didn't follow through. :(

Thanks, Paul Wilson
1/27/2006 1:33:17 PM
Before I rush into a commitment like that, I will find out what more, if anything, needs to be done to get it to the point I would like it for my devious testing purposes and then I will let you know. I agree that it is a great little library and am also amazed that someone didn't take it further. In fact, the other day when I went searching for it, having remembered reading about it when you first created it, I was in disbelief that it was stagnant - here you open sourced it and no one was developing it, talking much about it, etc. I did see that a few people have talked about it (http://www.dotnetwhole.markfarm.com/Articles/DataXml.htm) and modified it (http://blog.opennetcf.org/ayakhnin/CategoryView.aspx?category=Xml%20Data%20Provider), but not much else.

Well, okay - I will work on it some and let you know, and if anyone else is interested in using it for the same purposes as I and would like to help, they can contact me or obviously do it on their own. Hopefully more people that use WORM will realize the benefits of unit testing and see how this tool complements it so very well for that purpose; I do! :) I would also love to hear about anyone else that uses unit testing with WORM and how they are doing that.

Jason
1/27/2006 6:46:57 PM By the way, I too am interested in seeing more unit tests. :)

A few people have promised to build some for the mapper in the past, but for some reason they haven't ever came through -- it may be they are just understandably too busy, but it may be that its not as easy as you would hope to unit test generic data access. Now I have seen people with unit tests for their own apps that use the mapper -- that's not too hard, although admittedly I'm still not doing it often enough to make it routine for me thinking yet.

Thanks, Paul Wilson
6/26/2006 3:26:19 PM

Hi,

I’m also getting the "XmlDbParameter: Parameter Direction must be Input" exception. Did someone already fixed this problem?

 

Thanks,

 

Sander