Skip to content

Commit c5bcf5a

Browse files
committed
exposed the entity type from ToManyBase
1 parent 8ddda12 commit c5bcf5a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/FluentNHibernate/Mapping/ManyToManyPart.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
4-
using System.Linq.Expressions;
5-
using System.Reflection;
6-
using System.Xml;
73
using FluentNHibernate.Mapping.Builders;
84
using FluentNHibernate.MappingModel;
95
using FluentNHibernate.MappingModel.Collections;
106
using FluentNHibernate.Utils;
11-
using NHibernate.Persister.Entity;
127

138
namespace FluentNHibernate.Mapping
149
{
1510
public class ManyToManyPart<TChild> : ToManyBase<ManyToManyPart<TChild>, TChild, ManyToManyMapping>
1611
{
1712
private readonly IList<FilterMapping> childFilters = new List<FilterMapping>();
18-
private readonly Type entity;
1913
private readonly FetchTypeExpression<ManyToManyPart<TChild>> fetch;
2014
private readonly NotFoundExpression<ManyToManyPart<TChild>> notFound;
21-
private readonly Type childType;
2215
readonly AttributeStore sharedColumnAttributes = new AttributeStore();
2316

2417
public ManyToManyPart(Type entity, Member property)
2518
: this(entity, property, property.PropertyType)
2619
{
27-
childType = property.PropertyType;
2820
}
2921

3022
protected ManyToManyPart(Type entity, Member member, Type collectionType)
3123
: base(entity, member, collectionType)
3224
{
33-
this.entity = entity;
34-
childType = collectionType;
35-
3625
fetch = new FetchTypeExpression<ManyToManyPart<TChild>>(this, value => collectionAttributes.Set(x => x.Fetch, value));
3726
notFound = new NotFoundExpression<ManyToManyPart<TChild>>(this, value => relationshipMapping.NotFound = value);
3827

src/FluentNHibernate/Mapping/ToManyBase.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public abstract class ToManyBase<T, TChild, TRelationshipAttributes> : ICollecti
2929
private Func<AttributeStore, ICollectionMapping> collectionBuilder;
3030
protected IndexMapping indexMapping;
3131
protected Member member;
32-
private Type entity;
32+
private readonly Type entity;
3333
ElementMapping elementMapping;
3434
CacheMapping cache;
3535

@@ -52,6 +52,15 @@ protected ToManyBase(Type entity, Member member, Type type)
5252
keyMapping.AddDefaultColumn(new ColumnMapping { Name = entity.Name + "_id" });
5353
}
5454

55+
/// <summary>
56+
/// Return the type of the owning entity
57+
/// </summary>
58+
/// <returns>Type</returns>
59+
public Type EntityType
60+
{
61+
get { return entity.GetType(); }
62+
}
63+
5564
/// <summary>
5665
/// Specify how the foreign key is configured.
5766
/// </summary>

0 commit comments

Comments
 (0)