开发者

How can I group on a nested property as well as having the same parent in LINQ?

Merged with How can I group on a nested property as well as having the same parent in LINQ?.

I'm new to LINQ, and I'm having trouble organizing this query to return what I want. First off, some background. I'm working on a music game, which supports custom notecharts. Notecharts contain metadata specific to a collection of notes, such as number of notes, difficulty, and BPM. One or more notecharts can be in a simfile, sort of a container of notecharts. A simfile has its own "simfile-level" metadata as well, such as a path to a song file, song title, song artist, etc. So, I have classes of the following form:

class Notechart {
    public List<Note> Notes { get; }
    public uint BPM { get; set; }
    public uint Difficulty { get; set; }
}

class Simfile {
    public List<Notechart> Notecharts { get; }
    public string SongPath { get; set; }
    public string SongTitle { get; set; }
    public string SongArtist { get; set; }
    // Other "album-specific" fields...
}

For a given List<Simfile>, I'd like to get a list of all Notecharts contained in all the Simfiles grouped by the following criteria (in order of precedence):

1) The value of Notechart.<Value>, where <Value> is any of the notechart-specific fields or a transformation of a notechart-specific field (e.g. any BPMs between 130-150)

2) Being 开发者_运维技巧in the same Simfile (since if two notecharts within a simfile have the same criteria as above, I would want to display them together with information from the simfile)

Is there anyway to represent this in LINQ? MyElement and MyElementCollection don't implement any custom equality checking, so I don't believe testing if it is in the list will work. Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜