Exemplo n.º 1
0
 /// <summary>
 /// Perform an <c>update versioned</c> on all entities selected by the specified query, using an anonymous initializer for specifying setters.
 /// The update operation is performed in the database without reading the entities out of it.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
 /// <param name="source">The query matching the entities to update.</param>
 /// <param name="expression">The assignments expressed as an anonymous object, e.g.
 /// <c>x => new { Name = x.Name, Age = x.Age + 5 }</c>. Unset members are ignored and left untouched.</param>
 /// <returns>The number of updated entities.</returns>
 public static int UpdateVersioned <TSource>(this IQueryable <TSource> source, Expression <Func <TSource, object> > expression)
 {
     return(ExecuteUpdate(source, DmlExpressionRewriter.PrepareExpressionFromAnonymous(source.Expression, expression), true));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Insert all entities selected by the specified query, using an anonymous initializer for specifying setters. <typeparamref name="TTarget"/>
 /// must be explicitly provided, e.g. <c>source.InsertInto&lt;Cat, Dog&gt;(c => new {...})</c>. The insert operation is performed in the
 /// database without reading the entities out of it.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
 /// <typeparam name="TTarget">The type of the entities to insert. Must be explicitly provided.</typeparam>
 /// <param name="source">The query matching entities source of the data to insert.</param>
 /// <param name="expression">The expression projecting a source entity to an anonymous object representing
 /// the entity to insert.</param>
 /// <returns>The number of inserted entities.</returns>
 public static int InsertInto <TSource, TTarget>(this IQueryable <TSource> source, Expression <Func <TSource, object> > expression)
 {
     return(ExecuteInsert <TSource, TTarget>(source, DmlExpressionRewriter.PrepareExpressionFromAnonymous(source.Expression, expression)));
 }