An alternative to displaying a dictionary of lists?

I have a simple circuit that looks like this:

kl5cim.png

The idea is that there are users, departments, and threads. For each Department, the User can “launch” several threads to “bookmark” them (therefore, there can be many threads for the Department / User pair).

Ideally, I would like to use the following classes:

public class User
{
    public virtual int Id { get; protected set; }
    public virtual string Name { get; set; }
}

public class Department
{
    public virtual int Id { get; protected set; }
    public virtual string Name { get; set; }
    public virtual IDictionary<User, IList<StarredFlow>> StarredFlows { get; protected set; }

    public Department()
    {
        this.UserStarredFlows = new Dictionary<User, IList<StarredFlow>>();
    }
}

public class Flow
{
    public virtual int Id { get; protected set; }
    public virtual string Name { get; set; }

    protected Flow() { }
}

public class StarredFlow
{
    public virtual int Id { get; protected set; }
    public virtual User User { get; protected set; }
    public virtual Department EntryPoint { get; protected set; }
    public virtual Flow Flow { get; protected set; }
    public virtual string Name { get; protected set; }

    protected StarredFlow() { }

    public StarredFlow(User user, Department ep, Flow flow, string name)
    {
        this.User = user;
        this.EntryPoint = ep;
        this.Flow = flow;
        this.Name = name;
    }
}

This will get a fairly literal code:

var userStarredFlowsForDepartment = department.StarredFlows[currentUser];

However, NHibernate does not support the display of list dictionaries. I found a similar question / answer that involves moving IList<StarredFlow>to a new class and displaying it using the component. Unfortunately, FluentNHibernate does not support the mapping of a collection to components (there is no HasManymapping from components there).

NHibernate, . ? , session.Save(starredFlow) Query<StarredFlow>(), .

+5
1

, , . , , NHibernate , .

, Department , IQueryable:

public IEnumerable<StarredFlow> GetUserStarredFlows(IQueryable<StarredFlow> source,
                                                    User user)
{
    return source.Where(x => x.User == user)
                 .ToList(); //you could skip this depending on your usage
}

( ) IQueryable .

0

All Articles