Skip to content

Commit 8438f2a

Browse files
author
Iwanow, Mihail (EXT)
committed
Add autogenerated async code
1 parent 2823323 commit 8438f2a

File tree

20 files changed

+827
-447
lines changed

20 files changed

+827
-447
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System.Collections.Generic;
12+
using NHibernate.Criterion;
13+
using NHibernate.SqlCommand;
14+
using NHibernate.Transform;
15+
16+
namespace NHibernate.Test.NHSpecificTest.NH3848
17+
{
18+
using System.Threading.Tasks;
19+
using System.Threading;
20+
public class CriteriaTestFixtureAsync : FixtureAsync
21+
{
22+
protected override Task<IList<Customer>> GetCustomersWithFetchedOrdersWithoutRestrictionsAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
23+
{
24+
try
25+
{
26+
return session.CreateCriteria<Customer>()
27+
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin)
28+
.SetResultTransformer(new DistinctRootEntityResultTransformer())
29+
.ListAsync<Customer>(cancellationToken);
30+
}
31+
catch (System.Exception ex)
32+
{
33+
return Task.FromException<IList<Customer>>(ex);
34+
}
35+
}
36+
37+
protected override Task<IList<Customer>> GetCustomersWithOrdersEagerLoadedAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
38+
{
39+
try
40+
{
41+
return session.CreateCriteria<Customer>()
42+
.Fetch("Orders")
43+
.SetResultTransformer(new DistinctRootEntityResultTransformer())
44+
.ListAsync<Customer>(cancellationToken);
45+
}
46+
catch (System.Exception ex)
47+
{
48+
return Task.FromException<IList<Customer>>(ex);
49+
}
50+
}
51+
52+
protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
53+
{
54+
try
55+
{
56+
return session.CreateCriteria<Customer>()
57+
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber))
58+
.ListAsync<Customer>(cancellationToken);
59+
}
60+
catch (System.Exception ex)
61+
{
62+
return Task.FromException<IList<Customer>>(ex);
63+
}
64+
}
65+
66+
protected override Task<IList<Customer>> GetCustomersWithCompaniesByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
67+
{
68+
try
69+
{
70+
return session.CreateCriteria<Customer>()
71+
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber))
72+
.CreateAlias("Companies", "company", JoinType.LeftOuterJoin)
73+
.ListAsync<Customer>(cancellationToken);
74+
}
75+
catch (System.Exception ex)
76+
{
77+
return Task.FromException<IList<Customer>>(ex);
78+
}
79+
}
80+
81+
protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
82+
{
83+
try
84+
{
85+
return session.CreateCriteria<Customer>()
86+
.CreateCriteria("Orders", "Order", JoinType.LeftOuterJoin)
87+
.Add(Restrictions.Eq("Number", orderNumber))
88+
.SetResultTransformer(new DistinctRootEntityResultTransformer())
89+
.ListAsync<Customer>(cancellationToken);
90+
}
91+
catch (System.Exception ex)
92+
{
93+
return Task.FromException<IList<Customer>>(ex);
94+
}
95+
}
96+
97+
protected override Task<IList<Customer>> GetCustomersByNameUsingWhereClauseAsync(ISession session, string customerName, CancellationToken cancellationToken = default(CancellationToken))
98+
{
99+
try
100+
{
101+
return session.CreateCriteria<Customer>()
102+
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin)
103+
.Add(Restrictions.Eq("Name", "First Customer"))
104+
.SetResultTransformer(new DistinctRootEntityResultTransformer())
105+
.ListAsync<Customer>(cancellationToken);
106+
}
107+
catch (System.Exception ex)
108+
{
109+
return Task.FromException<IList<Customer>>(ex);
110+
}
111+
}
112+
113+
protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingSubqueriesAndByNameUsingWhereClauseAsync(ISession session, int orderNumber, string customerName, CancellationToken cancellationToken = default(CancellationToken))
114+
{
115+
try
116+
{
117+
var detachedCriteria = DetachedCriteria.For<Customer>()
118+
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber))
119+
.SetProjection(Projections.Id());
120+
121+
return session.CreateCriteria<Customer>()
122+
.CreateAlias("Orders", "order1", JoinType.LeftOuterJoin)
123+
.Add(Subqueries.PropertyIn("Id", detachedCriteria))
124+
.Add(Restrictions.Eq("Name", customerName))
125+
.SetResultTransformer(new DistinctRootEntityResultTransformer())
126+
.ListAsync<Customer>(cancellationToken);
127+
}
128+
catch (System.Exception ex)
129+
{
130+
return Task.FromException<IList<Customer>>(ex);
131+
}
132+
}
133+
134+
protected override Task<IList<Customer>> GetAllCustomersAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
135+
{
136+
try
137+
{
138+
return session.CreateCriteria<Customer>().ListAsync<Customer>(cancellationToken);
139+
}
140+
catch (System.Exception ex)
141+
{
142+
return Task.FromException<IList<Customer>>(ex);
143+
}
144+
}
145+
}
146+
}

0 commit comments

Comments
 (0)