Skip to content

Commit

Permalink
* FilterDefinitions are now also copied in Automapping.AlterModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Janssens authored and Tom Janssens committed Apr 19, 2010
1 parent d2f3887 commit 29058de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/FluentNHibernate/Automapping/AutoMapping.cs
Expand Up @@ -75,6 +75,9 @@ void IAutoClasslike.AlterModel(ClassMappingBase mapping)

foreach (var storedProcedure in storedProcedures)
mapping.AddStoredProcedure(storedProcedure.GetStoredProcedureMapping());

foreach (var filter in filters)
mapping.AddOrReplaceFilter(filter.GetFilterMapping());
}

protected override OneToManyPart<TChild> HasMany<TChild>(Member property)
Expand Down
Expand Up @@ -149,6 +149,11 @@ public void AddFilter(FilterMapping mapping)
mappedMembers.AddFilter(mapping);
}

public void AddOrReplaceFilter(FilterMapping mapping)
{
mappedMembers.AddOrReplaceFilter(mapping);
}

public void AddSubclass(SubclassMapping subclass)
{
subclasses.Add(subclass);
Expand Down Expand Up @@ -190,5 +195,6 @@ public override int GetHashCode()
return ((mappedMembers != null ? mappedMembers.GetHashCode() : 0) * 397) ^ (subclasses != null ? subclasses.GetHashCode() : 0);
}
}

}
}
10 changes: 10 additions & 0 deletions src/FluentNHibernate/MappingModel/MappedMembers.cs
Expand Up @@ -71,6 +71,15 @@ public IEnumerable<FilterMapping> Filters
get { return filters; }
}

public void AddOrReplaceFilter(FilterMapping mapping)
{
var filter = filters.Find(x => x.Name == mapping.Name);
if (filter != null)
filters.Remove(filter);
filters.Add(mapping);
}


public IEnumerable<StoredProcedureMapping> StoredProcedures
{
get { return storedProcedures; }
Expand Down Expand Up @@ -255,5 +264,6 @@ public override int GetHashCode()
return result;
}
}

}
}

4 comments on commit 29058de

@ragamuf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the status of this patch? Thanks.

@ToJans
Copy link
Owner

@ToJans ToJans commented on 29058de Feb 15, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should have been merged a few releases ago

@ragamuf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the changes in the master branch but the filter is still broken.

{"filter-def for filter named myFilterName was not found."}

@ragamuf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction, it is broken in the stable release branch.

fluentnhibernate-NH3.0-binary-1.2.0.694

Please sign in to comment.