@@ -474,7 +474,7 @@ IList<Cat> oldCats =
474474 Beginning with NHibernate 5.0, Linq queries can be used for inserting, updating or deleting entities.
475475 The query defines the data to delete, update or insert, and then <literal >Delete</literal >,
476476 <literal >Update</literal > and <literal >Insert</literal > queryable extension methods allow to delete it,
477- or instruct in which way it should updated or inserted. Those queries happen entirely inside the
477+ or instruct in which way it should be updated or inserted. Those queries happen entirely inside the
478478 database, without extracting corresponding entities out of the database.
479479 </para >
480480 <para >
@@ -487,7 +487,7 @@ IList<Cat> oldCats =
487487 <para >
488488 <literal >Insert</literal > method extension expects a NHibernate queryable defining the data source of
489489 the insert. This data can be entities or a projection. Then it allows specifying the target entity type
490- to insert, and how to convert source data to those target entities. Two forms of target specification
490+ to insert, and how to convert source data to those target entities. Three forms of target specification
491491 exist.
492492 </para >
493493 <para >
@@ -497,6 +497,13 @@ IList<Cat> oldCats =
497497 .Where(c => c.BodyWeight > 20)
498498 .Insert()
499499 .As(c => new Dog { Name = c.Name + "dog", BodyWeight = c.BodyWeight });]]> </programlisting >
500+ <para >
501+ Projections can be done with an anonymous object too, but it requires supplying explicitly the target type:
502+ </para >
503+ <programlisting ><![CDATA[ session.Query<Cat>()
504+ .Where(c => c.BodyWeight > 20)
505+ .Insert()
506+ .As<Dog>(c => new { Name = c.Name + "dog", BodyWeight = c.BodyWeight });]]> </programlisting >
500507 <para >
501508 Or using assignments:
502509 </para >
@@ -507,7 +514,7 @@ IList<Cat> oldCats =
507514 .Set(d => d.Name, c => c.Name + "dog")
508515 .Set(d => d.BodyWeight, c => c.BodyWeight));]]> </programlisting >
509516 <para >
510- In both cases, unspecified properties are not included in the resulting SQL insert.
517+ In all cases, unspecified properties are not included in the resulting SQL insert.
511518 <link linkend =" mapping-declaration-version" ><literal >version</literal ></link > and
512519 <link linkend =" mapping-declaration-timestamp" ><literal >timestamp</literal ></link > properties are
513520 exceptions. If not specified, they are inserted with their <literal >seed</literal > value.
@@ -523,7 +530,7 @@ IList<Cat> oldCats =
523530 <para >
524531 <literal >Update</literal > method extension expects a queryable defining the entities to update.
525532 Then it allows specifying which properties should be updated with which values. As for
526- <literal >Insert</literal >, two forms of target specification exist.
533+ <literal >Insert</literal >, three forms of target specification exist.
527534 </para >
528535 <para >
529536 Using projection to updated entity:
@@ -532,6 +539,13 @@ IList<Cat> oldCats =
532539 .Where(c => c.BodyWeight > 20)
533540 .Update()
534541 .As(c => new Cat { BodyWeight = c.BodyWeight / 2 });]]> </programlisting >
542+ <para >
543+ Projections can be done with an anonymous object too:
544+ </para >
545+ <programlisting ><![CDATA[ session.Query<Cat>()
546+ .Where(c => c.BodyWeight > 20)
547+ .Update()
548+ .As(c => new { BodyWeight = c.BodyWeight / 2 });]]> </programlisting >
535549 <para >
536550 Or using assignments:
537551 </para >
@@ -541,7 +555,7 @@ IList<Cat> oldCats =
541555 .Assign(a => a
542556 .Set(c => c.BodyWeight, c => c.BodyWeight / 2));]]> </programlisting >
543557 <para >
544- In both cases, unspecified properties are not included in the resulting SQL update. This could
558+ In all cases, unspecified properties are not included in the resulting SQL update. This could
545559 be changed for <link linkend =" mapping-declaration-version" ><literal >version</literal ></link > and
546560 <link linkend =" mapping-declaration-timestamp" ><literal >timestamp</literal ></link > properties:
547561 using <literal >UpdateVersioned</literal > instead of <literal >Update</literal > allows incrementing
0 commit comments