/// <summary> /// Given a list of Models with ShardKey keys, returns a distinct list of shard Ids, except for the shard Id specified. /// Useful for querying foreign shards after the primary shard has returned results. /// </summary> /// <param name="shardId"></param> /// <param name="records">The list of models to evaluate.</param> /// <returns>A ShardsValues collection, with the shards listed and values not set.</returns> public static ShardsValues ShardListForeign <TModel>(short shardId, IList <TModel> records) where TModel : IKeyedModel <TRecord, TChild, TGrandChild, TGreatGrandChild> { var result = new ShardsValues(); foreach (var record in records) { if (!record.Key.ShardId.Equals(shardId) && !result.Shards.ContainsKey(record.Key.ShardId)) { result.Add(record.Key.ShardId); } } return(result); }
public static ShardsValues ShardListForeign(short shardId, IList <ShardKey <TRecord, TChild, TGrandChild, TGreatGrandChild> > records) { var result = new ShardsValues(); foreach (var record in records) { if (!record.ShardId.Equals(shardId) && !result.Shards.ContainsKey(record.ShardId)) { result.Add(record.ShardId); } } return(result); }
/// <summary> /// Given a list of Models with ShardKChild keys, returns a distinct list of shard Ids, except for the shard Id specified. /// Useful for querying foreign shards after the primary shard has returned results. /// </summary> /// <param name="shardId">The shard id of the shard to exclude. This is typically the current shard and this function is used to determine if any records are foreign to it.</param> /// <param name="records">The list of models to evaluate.</param> /// <returns>A ShardsValues collection, with the shards listed. The values dictionary will be null.</returns> public static ShardsValues ToShardsValues <TModel>(IList <IKeyedModel <TRecord, TChild, TGrandChild, TGreatGrandChild> > records) where TModel : IKeyedModel <TRecord, TChild, TGrandChild, TGreatGrandChild> { var result = new ShardsValues(); foreach (var record in records) { if (!result.Shards.ContainsKey(record.Key.ShardId)) { result.Add(record.Key.ShardId); } } return(result); }