private static IAppendableExpr ZipOn(IExpr[] outerKeys, IExpr[] innerKeys) { if (outerKeys.Length != innerKeys.Length) { throw new Exception("Inner and Outer key selectors must specify the same number of keys"); } IAppendableExpr on = Expr.Empty; for (int n = 0; n < outerKeys.Length && n < innerKeys.Length; n++) { on = on.And(Expr.Eq(outerKeys[n], innerKeys[n])); } return(on); }
internal static IExpr IdentityExpr <T>(T value) { var reflection = StencilContext.ReflectionServices; if (reflection == null) { throw new MissingReflectionException(); } var metadata = EnsureMetadata(typeof(T)); IAppendableExpr result = Expr.Empty; foreach (var item in metadata.Keys) { var keyName = (Variable)item.Key; var keyValue = new Literal(reflection.GetValue(item, value)); result = result.And(Expr.Eq(keyName, keyValue)); } return(result); }