WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

Update: WilsonORMapper v4.1.1.0 (8/13/2005) includes the following:
  • Added new InitialState.Updated enum value for the StartTracking method.
  • This allows immediate PersistChanges -- useful for distributed systems.
  • Now supports generic relation collections -- even for the lazy-load case.
  • This feature was added by Paul Welter -- his templates are also updated.
By the way, after looking at Paul's code that nicely creates the generic relation collections, I then recalled why I hadn't done that myself -- I couldn't figure out how to do what he did. I remember even doing some googling and convincing myself that you simply could not have a generic type created where the type itself was a variable -- so I just gave up and forgot it. So congratulations Paul -- you're a generic wizard and you have made the ORMapper much better !
Published Saturday, August 13, 2005 2:28 PM by PaulWilson

Comments

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

Thanks for the compliments though I must confess I had to ask around for the answer as well. :) I've blogged about how it is done.

~ Paul

Saturday, August 13, 2005 7:18 PM by Paul Welter

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

COOL, thanks

Sunday, August 14, 2005 4:44 AM by ccBoy

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

So how do you do it then? I had exactly the same problem Mr Wilson described I couldn't figure out how to pass a generic type where the type itself was a variable?

Paul can you post some indicative code?

Tuesday, August 16, 2005 2:08 AM by Alex James

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

Paul Welter details on his blog, but here's the simple code snippet:

private BindingFlags internalFlags = BindingFlags.CreateInstance | (BindingFlags.NonPublic | BindingFlags.Instance);
Type genericType = typeof(CustomType<>).MakeGenericType(type);
object[] args = new object[] { ... };
relations = Activator.CreateInstance(genericType, internalFlags, null, args, null, null);

Tuesday, August 16, 2005 5:41 AM by Paul Wilson

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

Aargh... I wish I had run into this post a while earlier because I struggled with this one for quite a while as well before figuring it out. Generics for all the power they present are going to take some time to digest and figure out all the oddities that they represent to the type system.

Actually there's a slightly easier way:

this.m_GenericEntity = Activator.CreateInstance<EntityType>();

Tuesday, August 16, 2005 11:53 PM by Rick Strahl

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

Rick: That work's great if you know the whole type (RootType<InnerType>) as a variable, but it doesn't work if both parts are variables.

Wednesday, August 17, 2005 5:21 AM by Paul Wilson

# re: WilsonORMapper v4.1.1 Released -- With a Big Thanks to Paul Welter

Sheesh. You guys are all way over my head. Now I have a reason to start playing with .Net 2.0 - just so I can play and learn about all this stuff and keep up with the conversation.

Wednesday, August 17, 2005 5:29 AM by Tim Haines

Leave a Comment

(required) 
(required) 
(optional)
(required)