{"action":"created","issue":{"url":"https://api.github.com/repos/schotime/NPoco/issues/170","labels_url":"https://api.github.com/repos/schotime/NPoco/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/schotime/NPoco/issues/170/comments","events_url":"https://api.github.com/repos/schotime/NPoco/issues/170/events","html_url":"https://github.com/schotime/NPoco/issues/170","id":77670674,"number":170,"title":"FetchBy is gone, advice is needed","user":{"login":"konstk","id":12333843,"avatar_url":"https://avatars.githubusercontent.com/u/12333843?v=3","gravatar_id":"","url":"https://api.github.com/users/konstk","html_url":"https://github.com/konstk","followers_url":"https://api.github.com/users/konstk/followers","following_url":"https://api.github.com/users/konstk/following{/other_user}","gists_url":"https://api.github.com/users/konstk/gists{/gist_id}","starred_url":"https://api.github.com/users/konstk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konstk/subscriptions","organizations_url":"https://api.github.com/users/konstk/orgs","repos_url":"https://api.github.com/users/konstk/repos","events_url":"https://api.github.com/users/konstk/events{/privacy}","received_events_url":"https://api.github.com/users/konstk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-18T14:11:33Z","updated_at":"2015-05-20T23:27:23Z","closed_at":null,"body":"I have tried to update to the latest version, but with the FetchBy gone we cannot use it. The Query<T> simply does not have the same power, a lot of our code is now broken.\r\n\r\nWe were able to construct Linq queries to pass the by to ANY IDatabase (via repositories), where we could optionally make them part of a transaction or execute against the replica. We could control the execution of the query or check the validity. Now, with QueryProvider<T> directly coupled to specific IDatabase right from the start and directly exposing ToList() etc methods, all DAL logic cannot be contained within repositories. Anyone who makes use of IQueryProvider<T> can just call ToList() whenever and wherever they feel like and it will hit the database (possibly wrong replica).\r\n```C#\r\nFunc<SqlExpression<Class1>, SqlExpression<Class1>> sql = m => m.Where(x => x.Nr == nr);\r\nif (!includeExpired)\r\n    sql += m => m.Where(x => x.EndDate >= DateTime.Today || x.EndDate == null);\r\n...\r\n...\r\nDatabase1.FetchBy(sql);\r\nDatabase2.FetchBy(sql);\r\n```\r\nHow do we do it with suggested Query<T> ? Examples?"},"comment":{"url":"https://api.github.com/repos/schotime/NPoco/issues/comments/104070491","html_url":"https://github.com/schotime/NPoco/issues/170#issuecomment-104070491","issue_url":"https://api.github.com/repos/schotime/NPoco/issues/170","id":104070491,"user":{"login":"schotime","id":202923,"avatar_url":"https://avatars.githubusercontent.com/u/202923?v=3","gravatar_id":"","url":"https://api.github.com/users/schotime","html_url":"https://github.com/schotime","followers_url":"https://api.github.com/users/schotime/followers","following_url":"https://api.github.com/users/schotime/following{/other_user}","gists_url":"https://api.github.com/users/schotime/gists{/gist_id}","starred_url":"https://api.github.com/users/schotime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schotime/subscriptions","organizations_url":"https://api.github.com/users/schotime/orgs","repos_url":"https://api.github.com/users/schotime/repos","events_url":"https://api.github.com/users/schotime/events{/privacy}","received_events_url":"https://api.github.com/users/schotime/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T23:27:23Z","updated_at":"2015-05-20T23:27:23Z","body":"My bad. Firstly Type is your type eg. User\r\nThen you can use this.\r\n\r\n```csharp\r\nvar where = NPoco.Expressions.PredicateBuilder.True<User>();\r\nwhere = where.And(x => x.Name == \"Name\");\r\nvar query = db.Query<User>().Where(where).ToList();\r\n```\r\n"}}