{"action":"created","issue":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/1627","repository_url":"https://api.github.com/repos/linq2db/linq2db","labels_url":"https://api.github.com/repos/linq2db/linq2db/issues/1627/labels{/name}","comments_url":"https://api.github.com/repos/linq2db/linq2db/issues/1627/comments","events_url":"https://api.github.com/repos/linq2db/linq2db/issues/1627/events","html_url":"https://github.com/linq2db/linq2db/issues/1627","id":415170816,"node_id":"MDU6SXNzdWU0MTUxNzA4MTY=","number":1627,"title":"Default \"Where\" condition.(not a bug)","user":{"login":"YXMagnuMXY","id":33696606,"node_id":"MDQ6VXNlcjMzNjk2NjA2","avatar_url":"https://avatars0.githubusercontent.com/u/33696606?v=4","gravatar_id":"","url":"https://api.github.com/users/YXMagnuMXY","html_url":"https://github.com/YXMagnuMXY","followers_url":"https://api.github.com/users/YXMagnuMXY/followers","following_url":"https://api.github.com/users/YXMagnuMXY/following{/other_user}","gists_url":"https://api.github.com/users/YXMagnuMXY/gists{/gist_id}","starred_url":"https://api.github.com/users/YXMagnuMXY/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YXMagnuMXY/subscriptions","organizations_url":"https://api.github.com/users/YXMagnuMXY/orgs","repos_url":"https://api.github.com/users/YXMagnuMXY/repos","events_url":"https://api.github.com/users/YXMagnuMXY/events{/privacy}","received_events_url":"https://api.github.com/users/YXMagnuMXY/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-02-27T15:06:36Z","updated_at":"2019-02-27T17:09:49Z","closed_at":null,"author_association":"NONE","body":"Hi, my friends!\r\n\r\nI don't know the best option to work with in the next situation:\r\n\r\nI have a class generated from a table, for example \"USERS\", that has a flag - IsDeleted for one of the rows with the boolean value to true. This user is \"deleted\", and should not be used further.\r\n\r\nIs not a problem to do one time ```db.Users.Where(x=>!x.IsDeleted)```, but if I'm using the same table in many places, each time I should put the condition where, ```x.IsDeleted = false```.\r\n\r\nIs there any method that would let me write only ```db.Users.ToList()``` and will load the list of users that does not have the flag \"IsDeleted\" to true?\r\n\r\nI know that this is the place of creating issues only, but please help.\r\nIf this is not implemented, you can use this to create maybe new feature.\r\n\r\nThanks in advance!\r\n\r\n\r\n### Environment details\r\nlinq2db version: *2.6.3*\r\nDatabase Server: *E.g. PostgreSQL 10.3*\r\nDatabase Provider: *E.g. Npgsql 3.2.3*\r\nOperating system: *E.g. Windows 10 x64*\r\nFramework version: *.NET Framework 4.7.2*\r\n"},"comment":{"url":"https://api.github.com/repos/linq2db/linq2db/issues/comments/467947594","html_url":"https://github.com/linq2db/linq2db/issues/1627#issuecomment-467947594","issue_url":"https://api.github.com/repos/linq2db/linq2db/issues/1627","id":467947594,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2Nzk0NzU5NA==","user":{"login":"to11mtm","id":12536917,"node_id":"MDQ6VXNlcjEyNTM2OTE3","avatar_url":"https://avatars2.githubusercontent.com/u/12536917?v=4","gravatar_id":"","url":"https://api.github.com/users/to11mtm","html_url":"https://github.com/to11mtm","followers_url":"https://api.github.com/users/to11mtm/followers","following_url":"https://api.github.com/users/to11mtm/following{/other_user}","gists_url":"https://api.github.com/users/to11mtm/gists{/gist_id}","starred_url":"https://api.github.com/users/to11mtm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/to11mtm/subscriptions","organizations_url":"https://api.github.com/users/to11mtm/orgs","repos_url":"https://api.github.com/users/to11mtm/repos","events_url":"https://api.github.com/users/to11mtm/events{/privacy}","received_events_url":"https://api.github.com/users/to11mtm/received_events","type":"User","site_admin":false},"created_at":"2019-02-27T17:09:49Z","updated_at":"2019-02-27T17:09:49Z","author_association":"MEMBER","body":"You can handle this a couple of different ways.\r\n\r\nIf you are using T4 Templates, you may add an additional Partial class to the generated project:\r\n\r\n```\r\n//This should be in the same Project/Namespace as your T4 generated Model\r\nnamespace PostreSQLDataContext\r\n{\r\n    //This should be the same Class Name as your T4 Generated Model\r\n    public partial class MyGeneratedDataConnection : LinqToDB.Data.DataConnection\r\n    {\r\n        public IQueryable<Users> MyActiveUsers { get { return this.Users.Where(x=>!x.IsDeleted); } }\r\n    }\r\n}\r\n```\r\n\r\nYou may then use it as `db.MyActiveUsers.ToList()`, or even as `db.MyActiveUsers` in Queries:\r\n\r\n```\r\nvar myOrdersForActiveUsers = db.Orders.Where(o=> db.MyActiveUsers.Select(activeUser=>activeUser.ID).Contains(o.UserId)).ToList();\r\n```\r\n\r\nIf you are not using T4 Templates, you may follow the same pattern, instead adding the method to your existing class. (Or, you may still keep it as a partial if you'd like.)"}}
{"actor":{"display_login":"to11mtm"}}