|
| 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; |
| 12 | +using System.Collections.Generic; |
| 13 | +using NHibernate.Transform; |
| 14 | +using NUnit.Framework; |
| 15 | + |
| 16 | +namespace NHibernate.Test.NHSpecificTest.NH3848 |
| 17 | +{ |
| 18 | + using System.Threading.Tasks; |
| 19 | + using System.Threading; |
| 20 | + public class HqlTestFixtureAsync : FixtureAsync |
| 21 | + { |
| 22 | + [Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")] |
| 23 | + public override Task ChildCollectionsFromLeftOuterJoinWithOnClauseRestrictionOnCollectionShouldNotBeInSecondLevelCacheAsync() |
| 24 | + { |
| 25 | + throw new NotImplementedException(); |
| 26 | + } |
| 27 | + |
| 28 | + [Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")] |
| 29 | + public override Task ChildCollectionsFromLeftOuterJoinOnlyWithRestrictionShouldNotBeIn2LvlCacheAsync() |
| 30 | + { |
| 31 | + throw new NotImplementedException(); |
| 32 | + } |
| 33 | + |
| 34 | + [Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")] |
| 35 | + public override Task ChildCollectionsWithRestrictionShouldNotBeIn2LvlCacheAsync() |
| 36 | + { |
| 37 | + throw new NotImplementedException(); |
| 38 | + } |
| 39 | + |
| 40 | + [Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")] |
| 41 | + public override Task ChildCollectionsWithSelectModeFetchOnCollectionShouldNotBeInSecondLevelCacheAsync() |
| 42 | + { |
| 43 | + throw new NotImplementedException(); |
| 44 | + } |
| 45 | + |
| 46 | + protected override Task<IList<Customer>> GetCustomersWithOrdersEagerLoadedAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) |
| 47 | + { |
| 48 | + try |
| 49 | + { |
| 50 | + var query = session.CreateQuery("from Customer as c left join fetch c.Orders as o"); |
| 51 | + query.SetResultTransformer(new DistinctRootEntityResultTransformer()); |
| 52 | + return query.ListAsync<Customer>(cancellationToken); |
| 53 | + } |
| 54 | + catch (Exception ex) |
| 55 | + { |
| 56 | + return Task.FromException<IList<Customer>>(ex); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + //We can't write such query using hql, because we can't use 'with' clause when we're fetching collection. |
| 61 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 62 | + { |
| 63 | + throw new NotImplementedException(); |
| 64 | + } |
| 65 | + |
| 66 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 67 | + { |
| 68 | + try |
| 69 | + { |
| 70 | + var query = session.CreateQuery( |
| 71 | + "from Customer as c " + |
| 72 | + "left join fetch c.Orders as o " + |
| 73 | + "where o.Number = :number"); |
| 74 | + query.SetParameter("number", orderNumber); |
| 75 | + return query.ListAsync<Customer>(cancellationToken); |
| 76 | + } |
| 77 | + catch (Exception ex) |
| 78 | + { |
| 79 | + return Task.FromException<IList<Customer>>(ex); |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + protected override Task<IList<Customer>> GetCustomersByNameUsingWhereClauseAsync(ISession session, string customerName, CancellationToken cancellationToken = default(CancellationToken)) |
| 84 | + { |
| 85 | + try |
| 86 | + { |
| 87 | + var query = session.CreateQuery( |
| 88 | + "from Customer as c " + |
| 89 | + "left join fetch c.Orders as o " + |
| 90 | + "where c.Name = :name"); |
| 91 | + query.SetParameter("name", customerName); |
| 92 | + query.SetResultTransformer(new DistinctRootEntityResultTransformer()); |
| 93 | + return query.ListAsync<Customer>(cancellationToken); |
| 94 | + } |
| 95 | + catch (Exception ex) |
| 96 | + { |
| 97 | + return Task.FromException<IList<Customer>>(ex); |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + //We can't write such query using hql, because we can't use 'with' clause when we're fetching collection. |
| 102 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 103 | + { |
| 104 | + throw new NotImplementedException(); |
| 105 | + } |
| 106 | + |
| 107 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 108 | + { |
| 109 | + try |
| 110 | + { |
| 111 | + var query = session.CreateQuery( |
| 112 | + "from Customer as c " + |
| 113 | + "inner join fetch c.Orders as o " + |
| 114 | + "where o.Number = :number"); |
| 115 | + query.SetParameter("number", orderNumber); |
| 116 | + return query.ListAsync<Customer>(cancellationToken); |
| 117 | + } |
| 118 | + catch (Exception ex) |
| 119 | + { |
| 120 | + return Task.FromException<IList<Customer>>(ex); |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + //We can't write such query using hql, because we can't use 'with' clause when we're fetching collection. |
| 125 | + protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, string name, CancellationToken cancellationToken = default(CancellationToken)) |
| 126 | + { |
| 127 | + throw new NotImplementedException(); |
| 128 | + } |
| 129 | + |
| 130 | + protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchWithoutRestrictionsAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) |
| 131 | + { |
| 132 | + try |
| 133 | + { |
| 134 | + var query = session.CreateQuery( |
| 135 | + "from Customer as c " + |
| 136 | + "inner join fetch c.Orders as o " + |
| 137 | + "left join fetch c.Companies as cmp"); |
| 138 | + return query.ListAsync<Customer>(cancellationToken); |
| 139 | + } |
| 140 | + catch (Exception ex) |
| 141 | + { |
| 142 | + return Task.FromException<IList<Customer>>(ex); |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingSubqueriesAndByNameUsingWhereClauseAsync(ISession session, int orderNumber, string customerName, CancellationToken cancellationToken = default(CancellationToken)) |
| 147 | + { |
| 148 | + try |
| 149 | + { |
| 150 | + var query = session.CreateQuery( |
| 151 | + "from Customer as c " + |
| 152 | + "left join fetch c.Orders as o " + |
| 153 | + "where c.Name = :name and " + |
| 154 | + "c.Id in (select c1.Id from Customer as c1 left join c1.Orders as o2 where o2.Number = :number)"); |
| 155 | + query.SetParameter("name", customerName); |
| 156 | + query.SetParameter("number", orderNumber); |
| 157 | + query.SetResultTransformer(new DistinctRootEntityResultTransformer()); |
| 158 | + return query.ListAsync<Customer>(cancellationToken); |
| 159 | + } |
| 160 | + catch (Exception ex) |
| 161 | + { |
| 162 | + return Task.FromException<IList<Customer>>(ex); |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + //We can't write such query using hql, because we can't use 'with' clause when we're fetching collection. |
| 167 | + protected override Task<IList<Customer>> GetCustomersWithCompaniesByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken)) |
| 168 | + { |
| 169 | + throw new NotImplementedException(); |
| 170 | + } |
| 171 | + |
| 172 | + protected override Task<IList<Customer>> GetAllCustomersAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken)) |
| 173 | + { |
| 174 | + try |
| 175 | + { |
| 176 | + return session.CreateQuery("from Customer as c").ListAsync<Customer>(cancellationToken); |
| 177 | + } |
| 178 | + catch (Exception ex) |
| 179 | + { |
| 180 | + return Task.FromException<IList<Customer>>(ex); |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | +} |
0 commit comments