tag:blogger.com,1999:blog-4126985520350746834.post2164709827088407373..comments2024-03-28T07:00:21.554+00:00Comments on Chris O'Brien: Simple data access pattern for SharePoint listsChris O'Brienhttp://www.blogger.com/profile/10022906552670607366noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4126985520350746834.post-3868933580666637142008-11-30T23:35:00.000+00:002008-11-30T23:35:00.000+00:00@Anonymous,Since SPList doesn't implement IDisposa...@Anonymous,<BR/><BR/>Since SPList doesn't implement IDisposable it's not necessarily the same problem. I think you'd still need to pass in the SPWeb object so the caller can be responsible for it's disposal. However, off the top of my head I don't see any issues with the generic method using it's own logic to obtain the actual list since it doesn't require disposal.<BR/><BR/>HTH,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-53607664364938378762008-11-25T22:18:00.000+00:002008-11-25T22:18:00.000+00:00Hi Chris. I'd be interested to know how you'd stru...Hi Chris. I'd be interested to know how you'd structure the data access pattern you show if the list was unknown (unknown that is until the calling code calls).<BR/><BR/>Would you just swap out the SPWeb objects with SPList?<BR/><BR/>I appreciate your example is tailored to data access for one list but I'm coming from a content type wrapper point of view.<BR/><BR/>Thanks. Great article.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-55593929445180702712008-11-20T11:40:00.000+00:002008-11-20T11:40:00.000+00:00@Jeremy,Indeed - and the code-generation approach ...@Jeremy,<BR/><BR/>Indeed - and the code-generation approach you mention is one of the key aspects which makes the Linq approach possible with SharePoint - both the LINQ4SP and LinqToSharePoint implementations use it. I guess the only issue with this is that you have to go back and regenerate your proxy class (and recompile/deploy) whenever you add/change anything on this list. But presumably you're changing the code anyway, and this is what prompted you to make the list change. <BR/><BR/>So yes, I think for implementations which are looking for a 'patterns' approach to accessing SharePoint list data there are some good 'ORM' options there. I'm keen to use LINQ4SP on a real project soon. <BR/><BR/>In the meantime, something like my suggestion should hopefully serve as a quick enhancement to the default. Will look out for your post.<BR/><BR/>Cheers,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-91010481905563444912008-11-20T06:29:00.000+00:002008-11-20T06:29:00.000+00:00Great post Chris, I think I'm going to write a ful...Great post Chris, I think I'm going to write a full comment on my post on this one, but for now a few things off the top of my head.<BR/><BR/>This is leading towards the days of SQL, .NET, ASP.NET web projects where you had a SQL database with a schema and stored procs to do all the CRUD and then a .NET layer to structure this all then a ASP.NET page to present it all. The .NET layer could have a data layer and a business objects layer.<BR/>With what you are suggesting, basically SharePoint takes over from SQL, stored procs and .net data layer.<BR/><BR/>This could potentially be autogenerated, although the likes of MyGeneration/CodeSmith used to use foreign keys to understand relationships between tables which would now be lists...and SharePoint isn't that great at relational data. It handles data types and required fields well though.<BR/><BR/>In conclusion...would you really go this far with SharePoint Lists?Jeremy Thakehttps://www.blogger.com/profile/14264476485361437612noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-66783588109605769702008-11-20T06:28:00.000+00:002008-11-20T06:28:00.000+00:00>> and apologies to Sezai Komur for not gett...>> and apologies to Sezai Komur for not getting round to mailing a draft through earlier as I promised!<BR/><BR/><BR/>No problemo mate - love your work!<BR/><BR/>... and I love this pattern, its nice and simple and definetly better than doing nothing. The most common dev task people seem to do is get data out of lists. A simple pattern like this provides nice abstraction without being overly complex to implement. By leaving disposal up to the caller we can code static classes that do the DAL work and not have to worry about memory leaks caused by them.Sezai Komurhttps://www.blogger.com/profile/16510596786814172690noreply@blogger.com