I have an entity like so:

public class Land
    public virtual IDictionary<string, int> Damages { get; set; }
    // and other properties

Every time I try to use automapping with the following code:

var sessionFactory = Fluently.Configure()
    .Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Land>))

I get the following error:

{"The type or method has 2 generic parameter(s), but 1 generic argument(s) were
provided. A generic argument must be provided for each generic parameter."}

Can someone tell me what I’m doing wrong? Also, this is just a simple example. I have much more dictionaries than just this one.

asked Dec 21 ’09 at 22:33

Daniel T.

3 Answers


up vote
down vote



It is impossible with NHibernate.

answered Dec 30 ’09 at 9:28


Do you mean this to be impossible with Fluent NHibernate automapping, Fluent NHibernate as a whole (meaning with the fluent mappings as well), or NHibernate itself? – Daniel T. Jan 1 ’10 at 2:05
NHibernate itself. I do not know any ORM that could automap dictionary at present moment. – user224564 Jan 3 ’10 at 6:06

You’re right, you have to manually map it. Using Fluent, it’d be References(x => x.Dictionary).AsMap<int>("keyColumn").Element("valueColumn", c => c.Type<string>());. – Daniel T. Jan 11 ’10 at 5:18

Found some traces that this isn’t possible. Some traces, that it’s recently implemented.

Still investigating. 🙂

This looks quite promising (didn’t test yet).

So, in your case it should look like=>

public class LandMap : ClassMap<Land>
    public LandMap()

        HasMany(x => x.Damages)
                index => index.WithColumn("DamageType").WithType<string>(),
                element => element.WithColumn("Amount").WithType<int>()

Keep in mind – it should. I didn’t test it.

answered Dec 23 ’09 at 23:09

Arnis L.

That’s for fluent mapping. I’m looking for something that works for automapping because I have about 50 dictionaries across all my entities. – Daniel T. Dec 23 ’09 at 23:15
Ahhh… sorry. Somehow didn’t notice automapping. I’ll take a look. 🙂 – Arnis L. Dec 23 ’09 at 23:18

A possible workaround that should in theory work with automapping:

public class DamagesDictionary : Dictionary<string, int>


public class Land
   public virtual DamagesDictionary Damages { get; set; }
   // and other properties

or a more generic approach…

public class StringKeyedDictionary<T> : Dictionary<string, T>


public class Land
   public virtual StringKeyedDictionary<int> Damages { get; set; }
   // and other properties

answered Sep 29 ’10 at 6:55

I think this is an underrated answer – simpler sometimes to make another POCO with 2 properties on it (Key, Value) and reference that if you can’t be bothered to write the mappings (Lazy, yes.. Recommender, no… but…) – Macropus Nov 30 ’11 at 5:01

Your Answer


Sign up or login

Sign up using Google

Sign up using Facebook

Sign up using Stack Exchange

Post as a guest



By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you’re looking for?
Browse other questions tagged
or ask your own question.