Created
April 16, 2013 06:58
-
-
Save PureKrome/5393915 to your computer and use it in GitHub Desktop.
Sample RavenDb Index that has related documents. (Not 100% working)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GameServers_ConnectedClients : | |
AbstractIndexCreationTask<GameServer, GameServers_ConnectedClients.QueryResult> | |
{ | |
public GameServers_ConnectedClients() | |
{ | |
Map = gameServers => from gameserver in gameServers | |
where gameserver.IsActive | |
select new | |
{ | |
ServerName = gameserver.Name, | |
gameserver.GameType, | |
ClientGuids = gameserver.ConnectedClients.Keys, | |
ClientNames = gameserver.ConnectedClients.Values | |
.Select(x => LoadDocument<LogEntry>(x).Id) | |
}; | |
Index(x => x.ClientNames, FieldIndexing.Analyzed); | |
Sort(x => x.ClientNames, SortOptions.String); | |
} | |
public class QueryResult | |
{ | |
public string ServerName { get; set; } | |
public GameType GameType { get; set; } | |
public ICollection<Guid> ClientGuids { get; set; } | |
public ICollection<string> ClientNames { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment