Help needed with Linq To Sql Query

Posted by fearofawhackplanet on Stack Overflow See other posts from Stack Overflow or by fearofawhackplanet
Published on 2010-06-17T17:24:37Z Indexed on 2010/06/17 17:33 UTC
Read the original article Hit count: 220

alt text

I have the concept of valid/ordered transitions. So for example, it's not possible to move to status In progress from status Complete.

Current and Next in table StatusTransition are FK (StatusType.Id).

The Linq generator has created the following relations:

Child Property Name: StatusTransitions1
Parent Property Name: StatusType1
Participating Properties: StatusType.Id -> StatusTransition.Next

Child Property Name: StatusTransitions
Parent Property Name: StatusType
Participating Properties: StatusType.Id -> StatusTransition.Current

I'm normally ok with Linq but I'm having difficulty getting the list of valid Next StatusTypes from the Current status.

public List<StatusType> GetValidStatusTransitions(int statusId)
{
    // trying to write something like the following
    // (obviously not correct) 
    return _statusRepository
                .Where(s => s.Id == statusId)
                .Next.StatusTypes; 
}

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about object-relational-mapping