﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Karep commented on Ask Ayende: Handling filtering</title><description>Thanks for response. Now it's clear. Sometimes seems that you contradict yourself but I should probably take into account that some posts are from long time ago.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment17</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment17</guid><pubDate>Thu, 02 Feb 2012 22:00:59 GMT</pubDate></item><item><title>Ayende Rahien commented on Ask Ayende: Handling filtering</title><description>Karep,
Indeed, practices change over time, based on actual experience in the field and seeing what works and what doesn't work.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment16</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment16</guid><pubDate>Sun, 29 Jan 2012 11:22:20 GMT</pubDate></item><item><title>Karep commented on Ask Ayende: Handling filtering</title><description>Ayendt I'm rewatching Hibernating Rhinos #9 and you do exactly what you now say is wrong. You show how to create repositories. And you do use ORM with those repositories. A lot changed in your practices I see.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment15</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment15</guid><pubDate>Sat, 28 Jan 2012 12:36:15 GMT</pubDate></item><item><title>Matt Warren commented on Ask Ayende: Handling filtering</title><description>@John

See the docs here http://old.ravendb.net/documentation/triggers/read</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment14</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment14</guid><pubDate>Fri, 27 Jan 2012 12:21:18 GMT</pubDate></item><item><title>John commented on Ask Ayende: Handling filtering</title><description>"With RavenDB, you can define that inside a query listener."
Link please?</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment13</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment13</guid><pubDate>Wed, 25 Jan 2012 21:25:43 GMT</pubDate></item><item><title>Matt Hidinger commented on Ask Ayende: Handling filtering</title><description>@Ignacio Fuentes,

I wrote a post just for you, to describe how I handle this type of filtering in my EF infrastructure:

http://www.matthidinger.com/archive/2012/01/25/a-smarter-infrastructure-automatically-filtering-an-ef-4-1-dbset.aspx</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment12</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment12</guid><pubDate>Wed, 25 Jan 2012 20:11:33 GMT</pubDate></item><item><title>Benny Michielsen commented on Ask Ayende: Handling filtering</title><description>@Matt

You can add something specificationesque to solve the problem at hand. Throw the isession/idbcontext in a getactiveroot class which adds the filter</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment11</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment11</guid><pubDate>Wed, 25 Jan 2012 18:14:06 GMT</pubDate></item><item><title>Ignacio Fuentes commented on Ask Ayende: Handling filtering</title><description>@Ayende,

I dont think EF Code First supports that kind of default filtering.

http://stackoverflow.com/questions/6932209/how-can-i-have-entity-framework-return-related-objects-with-some-defaults</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment10</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment10</guid><pubDate>Wed, 25 Jan 2012 17:09:15 GMT</pubDate></item><item><title>Ayende Rahien commented on Ask Ayende: Handling filtering</title><description>Marco,
Caching is something that you do for a _specific scenario_, this isn't something that you do globally.
Therefor, you don't care what someone else is doing</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment9</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment9</guid><pubDate>Wed, 25 Jan 2012 14:08:33 GMT</pubDate></item><item><title>Marco commented on Ask Ayende: Handling filtering</title><description>Ayende

How do you control caching data when exposing ISession/IDbContext directly to your controllers when for example your working within a team environment? each team member would not know that the other person is storing the data in cache unless scanning the files.

</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment8</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment8</guid><pubDate>Wed, 25 Jan 2012 13:01:17 GMT</pubDate></item><item><title>Matt commented on Ask Ayende: Handling filtering</title><description>We're arguing the same thing then - except we have differing views of what should be abstracted and what is not.

You argue this should NOT be abstracted: 

http://ayende.com/blog/153153/northwind-starter-kit-review-refactoring-to-an-actual-read-model

I say it probably should.  I guess it all boils down to a matter of opinion.  

Funnily enough, this is something I've been wrestling with myself for some time now, so these posts are pertinent to me personally - thanks for the frequent posts and I hope they keep coming.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment7</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment7</guid><pubDate>Wed, 25 Jan 2012 12:21:35 GMT</pubDate></item><item><title>Ayende Rahien commented on Ask Ayende: Handling filtering</title><description>Matt,
I never said that there isn't a need to abstract some things out. What I said was that there isn't a need to do that in the common case.
In a typical app, you have cause to abstract 5% - 10% of the data access, because it is complicated / ugly.

The rest is trivial , and should be treated as such</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment6</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment6</guid><pubDate>Wed, 25 Jan 2012 12:07:18 GMT</pubDate></item><item><title>Matt commented on Ask Ayende: Handling filtering</title><description>Aren't filters globally applied though?  In which case, filters don't work if you want to expose the reverse but force it to be explicitly used instead of as the default?

Don't get me wrong - I absolutely see your point that in most cases repositories are overkill in the NHibernate world, but I do disagree with the premise that there is no room for abstraction to another layer for certain applications.  

I'm still not convinced there is an absolute for either approach, instead the best approach lies somewhere in the middle.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment5</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment5</guid><pubDate>Wed, 25 Jan 2012 11:58:31 GMT</pubDate></item><item><title>Ayende Rahien commented on Ask Ayende: Handling filtering</title><description>Matt,
I gave several example of how you can modify that using different methods, NHibernate, RavenDB, etc.
Most OR/M has some way to do those sort of things.

For the scenarios that you posit, NHibernate has support for filters, so it isn't a static decision, you can add/remove them.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment4</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment4</guid><pubDate>Wed, 25 Jan 2012 11:45:19 GMT</pubDate></item><item><title>Matt commented on Ask Ayende: Handling filtering</title><description>Just to elaborate on the previous comment, I'm using a trivial example to highlight the common need to filter out records without having developers implement WHERE statements all over the system.

When just IsActive = true is a requirement, that's no huge overhead, but what about (where IsVerified = true AND IsActive = true AND IsNotLockedOut = true)?</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment3</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment3</guid><pubDate>Wed, 25 Jan 2012 11:32:42 GMT</pubDate></item><item><title>Matt commented on Ask Ayende: Handling filtering</title><description>I don't agree the assumption is flawed - your context is different.  

The original comment was to do with a pattern of implementation, but the answer uses NHibernate to say that it's incorrect.

What if I'm not using NHibernate, and don't have filtering at my disposal, or anything like it?  

Or even if I am using NHib, what if there are valid use cases for fetching everything with IsActive = false - the DEFAULT retrieval mechanism should filter these out but in some cases I want to see them?  I don't want a global query override that prevents my data layer from returning the records.  

Leaving it up to the developers to always exclude the relevant records is  not a great idea on a large system, so I absolutely agree that having it as part of your infrastructure is 1st prize, but I'm not sold on the filtering suggestion being a valid alternative in all cases.  Extension methods, as mentioned in a previous post, may work here too, but still aren't optimal in my opinion.</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment2</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment2</guid><pubDate>Wed, 25 Jan 2012 11:28:17 GMT</pubDate></item><item><title>Colin Scott commented on Ask Ayende: Handling filtering</title><description>I've worked with systems that do that. It's a really great source of confusing NullReferenceExceptions when a record that is in the database doesn't get returned by an abstraction that doesn't in any way indicate that it does such filtering. It's also a hindrance when writing the code that has to deal with the inactive records as suddenly none of the common structure applies.

(The NullReferenceExceptions on records not being found is an entirely separate flaw)</description><link>http://ayende.com/153702/ask-ayende-handling-filtering#comment1</link><guid>http://ayende.com/153702/ask-ayende-handling-filtering#comment1</guid><pubDate>Wed, 25 Jan 2012 10:40:58 GMT</pubDate></item></channel></rss>