This project is read-only.

Hybrid AutoClassMap with AttributeClassMap

Feb 13, 2012 at 6:37 PM

I want to be able to create a Hybrid AutoClassMap/AttributeClassMap mapper.
Based on what I've seen from the code it is not possible to re-use a lot of the code unless I recompile the code base because the majority of the classes are marked as "internal". Any suggestions?

Feb 16, 2012 at 12:34 AM

Do you mind explaining your use case?  I'm not sure I understand why you would need this functionality.

Feb 16, 2012 at 1:25 AM

I am trying to implement something like this

public class User {

  public string Firstname {get;set;]
  public string Lastname {get;set;}
  public string DistinguishedName {get;set;}
  public string Company {get;set;}


Basically if the user doesn't want to remap a default attribute name and just creates a property that directly maps to a property of a class then I would like to use the default AutoClassMap however if the user does want to have an attribute be remapped to a specific property for better understanding such as Lastname instead of "sn" then they would have that ability also. Another problem that I am trying to solve is I would like to not force the user to have to specify the NamingContext as an attribute property because then it become hard coded and you are not able to read it from the config for Attribute based implementation which is a limitation especially if you are going from one environment to another (Dev to QA).

I hope that this makes sense.

BTW thanks a ton for this component, you've saved me a ton of work and it is a great reference implementation for exploring how to write a linq to "x" provider.

Feb 17, 2012 at 10:15 PM

I understand.  I've frozen features for the upcoming release, but I'll create a task  to make it easier to provide a custom auto mapping implementation.

As for the naming context, that's a limitation of attribute based mapping.  You can use class based mapping to solve this problem.  Also, in the next release you will be able to specify a naming context for any mapped object via the Query interface so you don't have to specify it upfront.

Implementing IQueryable is not an easy task and I would have been lost if not for Matt Warren.  His blog has a lot of good information: