File tree Expand file tree Collapse file tree 5 files changed +34
-12
lines changed
FluentNHibernate.Testing/FluentInterfaceTests Expand file tree Collapse file tree 5 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,14 @@ public void ChildWhereShouldSetAttributeOnRelationshipModel()
272
272
. ModelShouldMatch ( x => ( ( ManyToManyMapping ) x . Relationship ) . Where . ShouldEqual ( "some condition" ) ) ;
273
273
}
274
274
275
+ [ Test ]
276
+ public void GenericChildWhereShouldSetAttributeOnRelationshipModel ( )
277
+ {
278
+ ManyToMany ( x => x . BagOfChildren )
279
+ . Mapping ( m => m . ChildWhere ( x => x . Name == "Name" ) )
280
+ . ModelShouldMatch ( x => ( ( ManyToManyMapping ) x . Relationship ) . Where . ShouldEqual ( "Name = 'Name'" ) ) ;
281
+ }
282
+
275
283
[ Test ]
276
284
public void EntityNameShouldSetModelValue ( )
277
285
{
Original file line number Diff line number Diff line change 3
3
using System . Linq ;
4
4
using System . Linq . Expressions ;
5
5
using FluentNHibernate . Mapping ;
6
- using FluentNHibernate . Testing . DomainModel . Mapping ;
7
6
using NUnit . Framework ;
8
7
9
8
namespace FluentNHibernate . Testing . FluentInterfaceTests
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
+ using System . Linq . Expressions ;
4
5
using FluentNHibernate . Mapping . Providers ;
5
6
using FluentNHibernate . MappingModel ;
6
7
using FluentNHibernate . MappingModel . Collections ;
8
+ using FluentNHibernate . Utils ;
7
9
8
10
namespace FluentNHibernate . Mapping
9
11
{
@@ -327,6 +329,17 @@ public ManyToManyPart<TChild> ChildWhere(string where)
327
329
return this ;
328
330
}
329
331
332
+ /// <summary>
333
+ /// Sets the where clause for this relationship, on the many-to-many element.
334
+ /// Note: This only supports simple cases, use the string overload for more complex clauses.
335
+ /// </summary>
336
+ public ManyToManyPart < TChild > ChildWhere ( Expression < Func < TChild , bool > > where )
337
+ {
338
+ var sql = ExpressionToSql . Convert ( where ) ;
339
+
340
+ return ChildWhere ( sql ) ;
341
+ }
342
+
330
343
protected override CollectionMapping GetCollectionMapping ( )
331
344
{
332
345
var collection = base . GetCollectionMapping ( ) ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
+ using System . Linq . Expressions ;
4
5
using FluentNHibernate . MappingModel ;
5
6
using FluentNHibernate . MappingModel . Collections ;
7
+ using FluentNHibernate . Utils ;
6
8
7
9
namespace FluentNHibernate . Mapping
8
10
{
@@ -217,5 +219,16 @@ void EnsureGenericDictionary()
217
219
if ( ! ( childType . IsGenericType && childType . GetGenericTypeDefinition ( ) == typeof ( IDictionary < , > ) ) )
218
220
throw new ArgumentException ( member . Name + " must be of type IDictionary<> to be used in a ternary assocation. Type was: " + childType ) ;
219
221
}
222
+
223
+ /// <summary>
224
+ /// Sets the where clause for this one-to-many relationship.
225
+ /// Note: This only supports simple cases, use the string overload for more complex clauses.
226
+ /// </summary>
227
+ public OneToManyPart < TChild > Where ( Expression < Func < TChild , bool > > where )
228
+ {
229
+ var sql = ExpressionToSql . Convert ( where ) ;
230
+
231
+ return Where ( sql ) ;
232
+ }
220
233
}
221
234
}
Original file line number Diff line number Diff line change @@ -537,17 +537,6 @@ public T Generic()
537
537
return ( T ) this ;
538
538
}
539
539
540
- /// <summary>
541
- /// Sets the where clause for this one-to-many relationship.
542
- /// Note: This only supports simple cases, use the string overload for more complex clauses.
543
- /// </summary>
544
- public T Where ( Expression < Func < TChild , bool > > where )
545
- {
546
- var sql = ExpressionToSql . Convert ( where ) ;
547
-
548
- return Where ( sql ) ;
549
- }
550
-
551
540
/// <summary>
552
541
/// Sets the where clause for this one-to-many relationship.
553
542
/// </summary>
You can’t perform that action at this time.
0 commit comments