Mapping Dictionary<int,Driver>

Original Post Jeffrey Cameron's Avatar

Jeffrey Cameron

23 Apr, 2010 06:52 PM via web

Hey all,

I've really been trying my best to map this particular type of collection but I just can't seem to crack it. I've tried StackOverflow, the newsgroups and this site but none of the code examples I have tried have worked yet :(

Here is the property I am trying to map:

    public virtual IDictionary<int, Driver> StratumSpecificDrivers
    {
        get;
        set;
    }

Here is the mapping override I am using:

    public void Override(FluentNHibernate.Automapping.AutoMapping<Module> mapping)
    {
        mapping.HasManyToMany(x => x.StratumSpecificDrivers)
                    .AsMap<int>(index => index.Column("Stratum").Type<int>(), element => element.Column("DriverId").Type<Driver>())
                    .Table("ModuleDriverOverrides")
                    .Cascade.All();
    }

It might be worthwhile to note that there is also a property in this class that is of the same type but not in a dictionary:

    public virtual Driver DefaultDriver
    {
        get;
        set;
    }

Any help is appreciated!

  1. 2 Posted by Jeffrey Cameron on 24 Apr, 2010 01:24 PM

    Jeffrey Cameron 's Avatar

    I did some more digging and discovered I am getting an NRE around line 59 of ManyToManyPart.cs

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is two plus two?

    Recent Discussions

    05 Jul, 2010 10:29 PM
    05 Jul, 2010 12:45 PM
    05 Jul, 2010 12:42 PM
    05 Jul, 2010 12:17 PM
    05 Jul, 2010 12:12 PM

     

    03 Jul, 2010 12:26 AM
    02 Jul, 2010 02:17 PM
    02 Jul, 2010 08:18 AM
    02 Jul, 2010 12:20 AM
    01 Jul, 2010 10:14 PM