|
| 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>> GetCustomersWithOrdersEagerLoadedAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) |
| 23 | + { |
| 24 | + try |
| 25 | + { |
| 26 | + return |
| 27 | + session |
| 28 | + .CreateCriteria<Customer>() |
| 29 | + .Fetch("Orders") |
| 30 | + .SetResultTransformer(new DistinctRootEntityResultTransformer()) |
| 31 | + .ListAsync<Customer>(cancellationToken); |
| 32 | + } |
| 33 | + catch (System.Exception ex) |
| 34 | + { |
| 35 | + return Task.FromException<IList<Customer>>(ex); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 40 | + { |
| 41 | + try |
| 42 | + { |
| 43 | + return |
| 44 | + session |
| 45 | + .CreateCriteria<Customer>() |
| 46 | + .CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber)) |
| 47 | + .ListAsync<Customer>(cancellationToken); |
| 48 | + } |
| 49 | + catch (System.Exception ex) |
| 50 | + { |
| 51 | + return Task.FromException<IList<Customer>>(ex); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 56 | + { |
| 57 | + try |
| 58 | + { |
| 59 | + return |
| 60 | + session |
| 61 | + .CreateCriteria<Customer>() |
| 62 | + .CreateAlias("Orders", "order", JoinType.InnerJoin, Restrictions.Eq("Number", orderNumber)) |
| 63 | + .Fetch(SelectMode.Fetch, "Orders") |
| 64 | + .ListAsync<Customer>(cancellationToken); |
| 65 | + } |
| 66 | + catch (System.Exception ex) |
| 67 | + { |
| 68 | + return Task.FromException<IList<Customer>>(ex); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 73 | + { |
| 74 | + try |
| 75 | + { |
| 76 | + return |
| 77 | + session |
| 78 | + .CreateCriteria<Customer>() |
| 79 | + .Fetch(SelectMode.Fetch, "Orders") |
| 80 | + .CreateCriteria("Orders", JoinType.InnerJoin) |
| 81 | + .Add(Restrictions.Eq("Number", orderNumber)) |
| 82 | + .ListAsync<Customer>(cancellationToken); |
| 83 | + } |
| 84 | + catch (System.Exception ex) |
| 85 | + { |
| 86 | + return Task.FromException<IList<Customer>>(ex); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, string name, CancellationToken cancellationToken = default(CancellationToken)) |
| 91 | + { |
| 92 | + try |
| 93 | + { |
| 94 | + return |
| 95 | + session |
| 96 | + .CreateCriteria<Customer>() |
| 97 | + .CreateAlias("Orders", "order", JoinType.InnerJoin, Restrictions.Eq("Number", orderNumber)) |
| 98 | + .Fetch(SelectMode.Fetch, "Orders") |
| 99 | + .CreateAlias("Companies", "company", JoinType.LeftOuterJoin, Restrictions.Eq("Name", name)) |
| 100 | + .ListAsync<Customer>(cancellationToken); |
| 101 | + } |
| 102 | + catch (System.Exception ex) |
| 103 | + { |
| 104 | + return Task.FromException<IList<Customer>>(ex); |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchWithoutRestrictionsAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) |
| 109 | + { |
| 110 | + try |
| 111 | + { |
| 112 | + return |
| 113 | + session |
| 114 | + .CreateCriteria<Customer>() |
| 115 | + .Fetch(SelectMode.Fetch, "Orders") |
| 116 | + .CreateAlias("Orders", "order", JoinType.InnerJoin) |
| 117 | + .CreateAlias("Companies", "company", JoinType.LeftOuterJoin) |
| 118 | + .ListAsync<Customer>(cancellationToken); |
| 119 | + } |
| 120 | + catch (System.Exception ex) |
| 121 | + { |
| 122 | + return Task.FromException<IList<Customer>>(ex); |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + protected override Task<IList<Customer>> GetCustomersWithCompaniesByOrderNumberUsingOnClauseAsync( |
| 127 | + ISession session, |
| 128 | + int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 129 | + { |
| 130 | + try |
| 131 | + { |
| 132 | + return |
| 133 | + session |
| 134 | + .CreateCriteria<Customer>() |
| 135 | + .CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber)) |
| 136 | + .CreateAlias("Companies", "company", JoinType.LeftOuterJoin) |
| 137 | + .ListAsync<Customer>(cancellationToken); |
| 138 | + } |
| 139 | + catch (System.Exception ex) |
| 140 | + { |
| 141 | + return Task.FromException<IList<Customer>>(ex); |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 146 | + { |
| 147 | + try |
| 148 | + { |
| 149 | + return |
| 150 | + session |
| 151 | + .CreateCriteria<Customer>() |
| 152 | + .CreateCriteria("Orders", "Order", JoinType.LeftOuterJoin) |
| 153 | + .Add(Restrictions.Eq("Number", orderNumber)) |
| 154 | + .SetResultTransformer(new DistinctRootEntityResultTransformer()) |
| 155 | + .ListAsync<Customer>(cancellationToken); |
| 156 | + } |
| 157 | + catch (System.Exception ex) |
| 158 | + { |
| 159 | + return Task.FromException<IList<Customer>>(ex); |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | + protected override Task<IList<Customer>> GetCustomersByNameUsingWhereClauseAsync(ISession session, string customerName, CancellationToken cancellationToken = default(CancellationToken)) |
| 164 | + { |
| 165 | + try |
| 166 | + { |
| 167 | + return |
| 168 | + session |
| 169 | + .CreateCriteria<Customer>() |
| 170 | + .CreateAlias("Orders", "order", JoinType.LeftOuterJoin) |
| 171 | + .Add(Restrictions.Eq("Name", "First Customer")) |
| 172 | + .SetResultTransformer(new DistinctRootEntityResultTransformer()) |
| 173 | + .ListAsync<Customer>(cancellationToken); |
| 174 | + } |
| 175 | + catch (System.Exception ex) |
| 176 | + { |
| 177 | + return Task.FromException<IList<Customer>>(ex); |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingSubqueriesAndByNameUsingWhereClauseAsync( |
| 182 | + ISession session, |
| 183 | + int orderNumber, |
| 184 | + string customerName, CancellationToken cancellationToken = default(CancellationToken)) |
| 185 | + { |
| 186 | + try |
| 187 | + { |
| 188 | + var detachedCriteria = |
| 189 | + DetachedCriteria |
| 190 | + .For<Customer>() |
| 191 | + .CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber)) |
| 192 | + .SetProjection(Projections.Id()); |
| 193 | + |
| 194 | + return |
| 195 | + session |
| 196 | + .CreateCriteria<Customer>() |
| 197 | + .CreateAlias("Orders", "order1", JoinType.LeftOuterJoin) |
| 198 | + .Add(Subqueries.PropertyIn("Id", detachedCriteria)) |
| 199 | + .Add(Restrictions.Eq("Name", customerName)) |
| 200 | + .SetResultTransformer(new DistinctRootEntityResultTransformer()) |
| 201 | + .ListAsync<Customer>(cancellationToken); |
| 202 | + } |
| 203 | + catch (System.Exception ex) |
| 204 | + { |
| 205 | + return Task.FromException<IList<Customer>>(ex); |
| 206 | + } |
| 207 | + } |
| 208 | + |
| 209 | + protected override Task<IList<Customer>> GetAllCustomersAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) |
| 210 | + { |
| 211 | + try |
| 212 | + { |
| 213 | + return session.CreateCriteria<Customer>().ListAsync<Customer>(cancellationToken); |
| 214 | + } |
| 215 | + catch (System.Exception ex) |
| 216 | + { |
| 217 | + return Task.FromException<IList<Customer>>(ex); |
| 218 | + } |
| 219 | + } |
| 220 | + } |
| 221 | +} |
0 commit comments