WilsonORWrapper: better, stronger, (maybe) faster

About a month ago, I wrote about a major update coming to WilsonORWrapper, the code library/code generation templates I put together for Paul Wilson’s O/R Mapper. Finally, it’s available!

The source code, releases, API documentation, and some (but far from enough) how-to sections are available on the WilsonORWrapper project site.

For those who used the previous version of the wrapper, there are some major breaking changes in here, but it’s not incredibly time-consuming or difficult to make the transition. The namespace hierarchy is changed somewhat, the configuration settings are changed, and some core classes have different method names, but overall it shouldn’t take long to convert. (I converted a project with about 30 entity classes in about 60 minutes.)

Every few days, I’m going to add to the “how-to” documentation, focusing on a different part of the library each time. Until then, there’s still plenty of stuff to check out.

If you find an error, please create a ticket on the project site. If you have comments or suggestions, post them here or on the WilsonORWrapper project page on this blog.

22 thoughts on “WilsonORWrapper: better, stronger, (maybe) faster”

  • In the one project I converted, I was surprised by how easy it was. I expected it to be worse. It was easy enough to do global find/replace to change things as needed, and only a few places required more involved changes.

  • Hi,

    I build yesterday evening a little example with the new WilsonORWrapper. I tried to start the NUnit testdll but I got always an error saying the my connection string is not ok.
    I use MySQL and here is the code from app.config:

    Any idea what I am doing wrong?
    Thanks in advance for your help!

    By the way, after compiling the generated CodeSmith entity classes I got an compile error (in the *.generated.cs part), saying that he doesn’t know anything about an “ObjectHolder”.
    I added manually “using Wilson.ORMapper;” then I could compile without any issues.

  • No chance to publish the code with :

    connectionStrings
    add name=”TestData” providerName=”MySql.Data” connectionString=”Database=db_signalement;Data Source=localhost;User Id=xxx;Password=yyy”
    connectionStrings

  • Hi Brian,

    could you please delete my previous post after reading it. Pressed the “Submit Comment” to fast…
    Thank you!

  • @Marcel:

    I haven’t tested against MySQL, so let’s try to figure out what the causes could be.

    First: Have you set up the configuration section in your config file as outlined on this page: http://www.hosted-projects.com/trac/computersims/wilsonorwrapper/wiki/Configuration ? The “connectionString” for the WilsonORWrapper configuration section must match the name of the corresponding ConfigurationStrings entry.

    Next: Are you running the unit tests that are generated for your code, or the unit tests for the wrapper? I’ll assume the former, in which case the tests may fail if there is no data present. Can you provide the exact text of the error? (You can email it to me.)

    Finally: Try using a debug-compiled version of the wrapper and run a single Retrieve unit test. Send me the debug exception (which will include file name and line numbers).

    Sorry you’ve encountered issues — I’ll try to whip up a MySQL test on my end to see if I can find out more as well.

  • @Marcel:

    Regarding the CodeSmith error — I see the problem. If you have “ImplementIObjectHelper” turned off, the using Wilson.ORMapper will not be generated. However, this is needed for ManyToOne relationships. I’ll put in a fix that will be added in the next release (some time today).

  • Was able to get your framework up and running with minimal problems … very nice!

    Anyways, I’ll probably spend some time looking through the source code today so as to be fully comfortable using it in my ASP.NET apps … but so far it is looking very promising (I especially like your integration of log4net and NUnit as well as the ability to adopt a Data Mapper pattern OR take an Active Record approach). Also, I see you are building out a HOW-TO on your project site … here are some topics that I’d be interested in:

    1. Example of properly integrating your framework generated objects with the ObjectDataSource control. In particular, it would be nice to see it working with a fully functional Gridview control (e.g. paging, sorting, filtering and CRUD operations).

    2. Example of setting up and using log4net from within the framework generated code.

    3. Example of setting up and using ASP.NET and MemCache with the framework generated code.

    Thanks for this great piece of code.

  • @wayde,

    I agree that examples and use cases are of huge, and I want to get as many of them out there. In that light, if you whip up an example or sample project, feel free to send it to me and I’ll add it to the Examples folder of the distribution.

    Integrating log4net or NLog is quite easy — if you know how to configure log4net or NLog, you do that just as you always would. The wrapper is set to use the default configuration search paths. See the unit test config file for an example of both.

    Re: memcached, I’ve tested it by caching datasets and it works great. Current limitations dictate that it has to be running on the local host on the default port (11211), but hopefully that will change down the road. If memcached is running (download it and run it, default config works fine), just set up the wrapper to use it (Cache=Memcached in the config) and try using it. Again see the unit test.

    I’ll try to whip up something on the wiki/project site soon.

  • Hi Brian,

    Everything is ok, I could run the NUnit Tests also with my MySQL Database.
    If I use the “tests.nunit” for starting the NUint FrontEnd I get the error I described.

    If I open the NUnit Frontend and if I select the UserAppTests.dll manually
    then it works perfectly!
    So, don´t spend your time for checking if your framework works with MySql, it works!

    I have also started to write this evening a simple Console Application (entity classes
    have been generated in C#) in VB.Net , and everything I tried worked perfectly, inclusive transactions!

    Best regards,
    Marcel

  • @Marcel,

    Are you using a licensed version of the O/R mapper or a demo version? The demo version will give a license error when running outside Visual Studio, which means it’ll give an error when running in NUnit. Note that the O/R mapper DLL in the references folder is the demo version (for obvious reasons).

    Glad to hear you are having no problems otherwise! I’ll look into the unit tests to see if there’s a lingering issue.

    Sorry that the templates are C# only — if someone wants to convert them to VB.Net I’ll add them to the distribution.

  • Sure Brian!

    Since I’m working on this, I’ll work up an example application demonstrating how to configure your framework generated objects with the ObjectDataSource control and the radGrid control developed by Microsoft. Based on my pervious experience, I think I may have a few suggestions for you on modifications you may want to make in your codebase (and corresponding codesmith templates).

    When I have something … I’ll send it your way.

    – wayde

  • Thanks — keep in mind that the project is very much “open source/community”.

    And @marcel — if you’re still reading — I have successfully used this with MySQL. In fact, I used the exact same code against schematically-identical MySQL and MSSQL database — a very nice thing indeed. 🙂

  • How the heck do I download the source code??? There is a link to “browse source” on TRAC but how can I get it without downloading each file individually? I tried clicking on “Zip Archive” on the bottom but it gives me a permissions error. Finally, should I be downloading from the Trunk or the Branches?
    I am sooooo confused.

  • Hi Brian,

    I am still reading this blog. I am currently writing an VB.Net WinForms application based on your example (users, departments). As soon as I have finished this little demo project, I will zip you the whole project.

    Best regards,

    Marcel

  • Hello… it seems we found a problem with the GetHashCode() method of the Entities.

    We have an entity with a composite key of the following values:
    key1 = 44
    key2 = 1
    key3 = “published”

    We are trying to serialize the Entity to XML where the GetHashCode() method is called and generates a huge number wich is obviously beyond the int limit. This is where execution enters the following while loop of the GetHashCode() method which it never exits..

    while ( int.TryParse(hashstring, out hashcode) == false )
    hashcode = hashcode / 11;

    Are there any suggestions?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>