{"action":"closed","issue":{"url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/608","repository_url":"https://api.github.com/repos/MarimerLLC/cslaforum","labels_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/608/comments","events_url":"https://api.github.com/repos/MarimerLLC/cslaforum/issues/608/events","html_url":"https://github.com/MarimerLLC/cslaforum/issues/608","id":342529421,"node_id":"MDU6SXNzdWUzNDI1Mjk0MjE=","number":608,"title":"How to get the instance of the business object in my implementation of IInterceptDataPortal?","user":{"login":"jmarquesh","id":5407014,"node_id":"MDQ6VXNlcjU0MDcwMTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5407014?v=4","gravatar_id":"","url":"https://api.github.com/users/jmarquesh","html_url":"https://github.com/jmarquesh","followers_url":"https://api.github.com/users/jmarquesh/followers","following_url":"https://api.github.com/users/jmarquesh/following{/other_user}","gists_url":"https://api.github.com/users/jmarquesh/gists{/gist_id}","starred_url":"https://api.github.com/users/jmarquesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmarquesh/subscriptions","organizations_url":"https://api.github.com/users/jmarquesh/orgs","repos_url":"https://api.github.com/users/jmarquesh/repos","events_url":"https://api.github.com/users/jmarquesh/events{/privacy}","received_events_url":"https://api.github.com/users/jmarquesh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-18T23:45:57Z","updated_at":"2018-07-19T19:13:38Z","closed_at":"2018-07-19T19:13:38Z","author_association":"NONE","body":"**Short question:**\r\n\r\nCan I have access to my business object (BO) in ALL calls to ```Initialize``` and ```Complete``` in my ```IInterceptDataPortal``` implementation? For instance, in the ```Initialize``` of the Fetch operation.\r\n\r\n**Why do I need it:**\r\n\r\nI'm using an IoC container to resolve implementations of my data access. All is based on this post [\"Abstractions in CSLA\"](https://magenic.com/thinking/abstractions-in-csla) by @JasonBock. \r\n\r\nFollowing the advice of @rockfordlhotka:\r\n\r\n>More importantly, you might also look at Csla.Server.IInterceptDataPortal, which has Initialize and Complete methods where you can create and tear down your DI scope without having to clutter your root objects with that bit of plumbing.\r\n\r\nAlso in [\"More data portal enhancements for CSLA 4.5\"](http://www.lhotka.net/weblog/MoreDataPortalEnhancementsForCSLA45.aspx),  announcing ```IInterceptDataPortal```:\r\n\r\n>I suspect most people will put the container instance in Csla.Application.LocalContext to ensure it is easily and consistently available to all code regardless of runtime environment...\r\n\r\nAlso from @jonnybee: \r\n\r\n>In my opinion - you should not call Autfac directly to resolve dependencies in your own business code. Autofac should not be visible to the business code so that you could switch to another IoC container if required.\r\n\r\nSo, I want to resolve data access dependencies right before the start of the DataPortal operation and dispose them right after. I don't want to do it in the BO (advice from @jonnybee). I also want to store the dependency in a property of my BO, so I can use it in my DataPortal_XYZ code.\r\n\r\nI could use ```Initialize``` and ```Complete``` in my ```IInterceptDataPortal``` but there is not always an instance of the BO there. Sometimes the instance is available (in the ```Complete``` after a Fetch, etc.). But sometimes is not (in the ```Initialize``` right before the Fetch).\r\n\r\nWhat can I do?\r\n\r\nThank you for the time you took to read my question and for any help you can provide.\r\n\r\n**Version and Platform**\r\nCSLA version: 4.7.100\r\nOS: Windows\r\nPlatform: ASP.NET Core, MVC\r\n"}}
{"actor":{"display_login":"jmarquesh"}}