Skip to content

Instantly share code, notes, and snippets.

@PureKrome
Created April 16, 2013 06:58
Show Gist options
  • Save PureKrome/5393915 to your computer and use it in GitHub Desktop.
Save PureKrome/5393915 to your computer and use it in GitHub Desktop.
Sample RavenDb Index that has related documents. (Not 100% working)
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