Example #1
0
 /// <summary>
 /// Push the list result to the right context
 /// </summary>
 /// <typeparam name="TLeft">Source entity type</typeparam>
 /// <typeparam name="TRight">Destination entity type</typeparam>
 /// <param name="_">Bridge</param>
 /// <param name="predicate">A function for a condition to filter elements. (s => s.Id) </param>
 /// <param name="projection">A function to copy convert TLeft element to TRight element</param>
 /// <returns>One of BridgeResult</returns>
 public static BridgeResult PushMany <TLeft, TRight>(this IBridge _,
                                                     Expression <Func <TLeft, bool> > predicate,
                                                     Expression <Func <TLeft, TRight> > projection)
     where TLeft : class, new()
     where TRight : class, new()
 {
     return(ExecuteFunction(true, projection,
                            () => ExpressionQueryExtension.GetList(null, predicate),
                            (r, f) => ExpressionQueryExtension.InsertBulk(null, r.Select(l => f(l)).ToList())));
 }
Example #2
0
 /// <summary>
 /// Push the first result to the right context
 /// </summary>
 /// <typeparam name="TLeft">Source entity type</typeparam>
 /// <typeparam name="TRight">Destination entity type</typeparam>
 /// <param name="_">Bridge</param>
 /// <param name="predicate">A function for a condition to filter elements. (s => s.Id) </param>
 /// <param name="projection">A function to copy convert TLeft element to TRight element</param>
 /// <returns>One of BridgeResult</returns>
 public static BridgeResult Push <TLeft, TRight>(this IBridge _,
                                                 Expression <Func <TLeft, bool> > predicate,
                                                 Expression <Func <TLeft, TRight> > projection)
     where TLeft : class, new()
     where TRight : class, new()
 {
     return(ExecuteFunction(true, projection,
                            () => ExpressionQueryExtension.GetFirst(null, predicate),
                            (r, f) => ExpressionQueryExtension.Insert(null, f(r))));
 }