Paul Wilson's .NET Blog
Ramblings from the Creator of WilsonDotNet.com
-
Sam Smoot discusses DataSets and O/R Mappers (and Fruit)
Sam Smoot discusses DataSets and O/R Mappers -- excellent post -- and it mentions fruit too!
-
Does anyone really know what they are missing until they try it?
A few of my friends were recently talking about their favorite fruits when another friend walked up and said he avoided all fruits. His rationale was that fruits were bad for you, and don't taste good anyhow, so we would all do well to stop eating these fruits. Of course we told him he was very wrong and that fruits are not only very tasty, but also very healthy and part of a balanced diet. It turns out that this fellow had a bad experience once a very long time ago with some fruit that caused him to get a little sick. Now he is convinced, without a doubt, that all fruit must therefore be very bad for you, not to mention that all fruits taste bad. I thought it would be easy to point out all the scientific evidence that claims to prove fruit is actually very healthy for you, but his personal "proof" was that he was very healthy without fruit, so even if it wasn't unhealthy it also wasn't of any value.
Now if you knew this fellow you would get a good laugh since he's extremely overweight and out of shape from eating lots of junk, but so far he hasn't had to go to the doctor or hospital with any major problems -- but we know its probably just matter of time. So we next tried to encourage him to just try some fruits for himself, since this would prove quite well how tasty they really are, and then given time he would also come to realize that they were quite good for him too -- but he's convinced he knows far better. Its easy to just leave him be, but we also really believe this fellow is in very bad shape, even if he doesn't realize it himself -- so what should we do? We can't make him try some fruit, but I suppose we can continue to give him evidence fruit is healthy, and wouldn't we be very poor friends if we let him continue in his unhealthy ways, especially since he has a family to care for.
P.S. The subject of this story was changed to protect the innocent -- the real story was about o/R Mappers and business objects. -
What do you look for in O/R Mappers?
Jason Mauss is asking for your feedback on what you look for in O/R Mappers since he'll be working on a How To Select Guide very soon.
-
Craig Shoemaker's Polymorphic Podcast
Check out Craig Shoemaker's Polymorphic Podcast. He's had a lot of really good shows, including several about O/R Mapping. Yours truly is featured on his most recent one -- and while I sound better this time, I'm also facing reality that I just sound terrible no matter what. That's hard to accept since I used to do a lot of singing, but I guess speaking somehow isn't the same. :)
-
The Data Mapping Application Block
Lenny Fenster has released a preview version of the Data Mapping Application Block. It uses the Enterprise Library, although a modified Data Access Application Block. My understanding is that this will be rolled into the Enterprise Library sometime. I'd heard rumors of this being worked on for quite some time, so it was no surprise. I suppose you could think of it as the Enterprise Library's O/R Mapper -- kind of.
What do I mean by "kind of"? There are no objects here, unless you like typed datasets, and you're required to use stored procs, which is great if it were just an option. But if you like to use your own objects and/or want to avoid the bloat of datasets and/or enjoy the flexibility and maintainability of runtime generated dynamic sql, then you won't find what you're looking for in the Data Mapping Application Block.
Of couse, if you follow all of Microsoft's "guidance", and are already using the Enterprise Library, then this is probably exactly what you have been dreaming about.
-
How/Why I Added a Wiki for WilsonDotNet
I've had several users of my ORMapper and UIMapper suggest that I add a Wiki to WilsonDotNet -- and I agreed it was a good idea. My first problem was finding the time to setup a Wiki, since I'm typically pretty busy already with my work and other projects. Of course this shouldn't be a big deal I was told since there are already some really good Wikis freely available, like FlexWiki. So a while back I downloaded FlexWiki and proceeded to setup a simple test Wiki on my local system -- took about an hour or so. At this point I was convinced that this would work out, but I still needed to integrate the Wiki with the rest of my existing site.
And this is where things started to go downhill. First I wanted to allow anonymous users to read my Wiki, but I only wanted my existing subscribers to be able to edit and create topics -- yes, this isn't a "pure" Wiki concept, but its what I wanted to do. I proceeded to look through the documentation and I found that this was something that others had also requested -- and failed. I did more searches and again found more people wanting this type of feature, but it just isn't supported out of the box so far. Of course you can always modify the app yourself, since its open-source, but I discovered that the codebase is quite involved.
At this point I thought I would just try some modifications to the web.config file in the authentication/authorization sections. Surely this wouldn't be too hard, but things didn't work out so easily -- I think because the Wiki needed to be its own IIS app. So now I decided to just give up and try it on my real site, again since I don't have a lot of time to waste getting this to work. This resulted in discovering that you can't just create your Wiki locally and simply upload and expect the links to work correctly. Another search showed that I wasn't alone in finding this to be an issue -- and there doesn't appear to be any solution to this.
At this point I had certainly put in more than a couple of hours, although I didn't track it to say it was 4, 8, or more hours. So I tabled this whole Wiki thing for a good while, and then recently I decided to think about this Wiki thing in another way. What is a Wiki? Its a set of topics, viewable as formatted Html, which can be edited and/or created, and a history is kept too. If you think about it that way, a Wiki does not sound very hard at all -- especially if you use the FreeTextBox for Html edits. So I did it -- in 30 minutes at most! And in my opinion its far better, at least for me, since it integrates with my site too.
So there you have it. I have my own Wiki that fits seamlessly into my already existing site and ties into my existing set of users. Its also far easier to use for someone like myself that isn't up on all the special codes needed to edit/create the formatted Html because I'm just letting my users have the full power of the FreeTextBox -- maybe this isn't a "real" Wiki, but its better for me. I also maintain a complete history of all edits, although I haven't exposed this yet (if ever), which I do think is a good idea. And I got all of this up and running in no time at all -- far less when compared with trying to figure out an existing free Wiki.
-
Check out my "Real" NHibernate Example App
As most of you know that follow my blog, I not only have my own WilsonORMapper, but I've also been tinkering with NHibernate some. Why? I needed to use a "free" set of code for my recent presentation on O/R Mapping at the Atlanta Code Camp. Anyhow, here's the long promised link to download my "real" NHibernate example app. What do I mean by calling it "real"? Well to put it bluntly, my experience is that its impossible to find a realistic and decently complex app for NHibernate (or Hibernate). My example app is the exact same one I updated for my WilsonORMapper, except I modified it slightly to support NHibernate. This means that it is first of all a real and fully functioning WinForm app -- complete with data-binding in grids and all your basic CRUD. It also means that this example includes several types of primary keys, relationships, and inheritance -- and did I mention it works!
Sure there is lots of documentation for Hibernate (and thus for NHibernate too), including books, but the examples are either typically small snippets, and many are outdated and just don't work with NHibernate v0.8. Some people have criticized the small amount of documentation I have for my WilsonORMapper, and rightly so, but I've always included a real example app that goes a long way in getting people started -- and without this I found it quite difficult to get up to speed on NHibernate since I was forced to dig into scattered documents, forums, and just plain old-fashioned trial-and-error in many cases! Here's an example -- NHibernate has multiple ways to model related collections (sets, bags, lists, and maps), which certainly is an advantage if you need flexibility, but just try to figure out which one to use for a many-to-many related collection that you want to be bindable -- the answer is use the bag.
Anyhow, what's intriguing to me is how close both the basic approach and the mapping file syntax is for my WilsonORMapper and NHibernate -- they are remarkably similar and there's very little effort to switch between them. Of course there are certainly differences too -- NHibernate is more flexible if you need that (most don't), while my WilsonORMapper is a little easier (far simpler codebase), supports more databases (including Access), and provides DAL capabilities as well as O/R Mapping. Both mappers have features the other lacks -- but they both have the basic set of features that most people need -- and both work as my example apps demonstrate. What are some other features my WilsonORMapper has? Supports stored procedures, custom collection types, real batch updates/deletes, server-side paging, lazy-loading without keeping "session" open, interface to avoid reflection, null values even in .NET v1.1, and I'm sure there are others I could list.
What about NHibernate you ask? I can't do it much justice to be fair since I'm not that experienced with it, but a few come to mind: more caching options, normalized inheritance, built-in one-to-one, two-way graph syncs, more cascade options, eager load option -- and again there are bound to be more. But the basics are pretty similar (although I prefer my WilsonORMapper of course) -- so if you're an NHibernate fan, then please download and enjoy my "real" NHiberate example app -- and feel free to add your own comments here on either mapper (or others), although please include some real details if you do.
-
WilsonORMapper v4.0 Released -- Includes .NET v2.0 Generics and Nullable Types
My WilsonORMapper v4.0 has finally been released out of beta with support for another database inheritance type,
as well as .NET v2.0 support for generics and nullable types -- and even more OPath support thanks to Jeff Lanning.
Download the updated demo package which contains both the usual simple demo and a more complex example.
Update: WilsonORMapper v4.0.0.0 (5/26/2005) includes the following:
- Supports "shared inheritance" in the database using type discriminator.
- This is also referred to as "single table with type discriminator".
- Always supported "redundant inheritance" or "one table per concrete type".
- Added support for .NET v2.0 Generics and Nullable Types -- VS 2005 Beta.
- Allows you to initialize you own relation collections, as long as IList.
- Works for all new objects, as well as non-lazy cases for existing objects.
- QueryHelper GetExpression expanded with ComparisonOperators by Paul Welter.
- Also includes nearly complete OPath engine (Longhorn Specs) by Jeff Lanning.
- Added ExecuteScalar and GetDataSet methods to the Transaction class.
- Added defaultNamespace for types that do not include the Namespace.
- Breaking Change: ExecuteCommand/Update/Delete returns int (not bool).
- Bug Fixes: Enum support, ObjectSet indexer, two types with the same name.
- Bug Fixes: Exceptions and Parameter are now marked Serializable also.
- And a special thanks to Jeff Lanning for help with both OPath and Generics.
-
Wally McClure Releases .NET PodCast -- Guess Who is Interviewed
Wally McClure has released his first .NET PodCast -- including lots of good SQL 2005 stuff from Wally. Oh yea, he's also interviewed me for this PodCast -- although I wish my allergies hadn't been so bad since I sound terrible.
-
Preparing for the Atlanta Code Camp
I'm scheduled first thing in the morning to present an "Introduction to O/R Mapping" at the Atlanta Code Camp. I've given many presentations to my teams in the past, but this will be my first public presentation -- so wish me the best. Will I make a good trainer -- or should I stick to designing and implementing solutions for clients -- we'll find out tomorrow. :) Of course, as luck would have it, my allergies are acting up in a major way yesterday and today -- just like every May -- so hopefully I'll feel better. By the way, since code camps are supposed to be free code only, I'll be using NHibernate for my set of examples -- I've actually got a nice little reference app with both an NHibernate implementation and a WilsonORMapper implementation. It demos just about every type of relationship and key type, as well as making use of a lot of inheritance (supported in v4.0 of my mapper, currently in beta). I'll post both versions in the coming week or so, when mine gets out of beta -- I think the NHibernate crowd will appreciate it since I've failed to find a good example app in my search. Maybe I'll also share some of my experiences working with NHibernate, which isn't bad at all -- of course I still like mine better. :) Finally, for all those who have asked, I've added a Wiki to my WilsonDotNet site where anyone can view it but only subscribers can edit it -- maybe I'll share some information about why I did it the way I have soon also.