To quickly start using this project, you can just download the project, add it to your solution and instantiate a SPGenericRepository with any of the build-in content types.

E.g.:

string siteUrl = "http://mysiteurl.local";
string documentListName = "Documents";

using (var site = new SPSite(siteUrl))
{
     using (var web = site.OpenWeb())
     {
           var documentsList = web.Lists[documentListName];
           
           // Create Repository
           var documentsRepository = new SPGenericRepository<ItemContentType, ItemContentTypeDto>(documentsList);
           
           // Get all items 
           List<ItemContentTypeDto> items = documentsRepository .GetAll();

           foreach (var item in items)
           {

                // Access to the typed properties on the Dto
                Console.Out.WriteLine(item.Id);
                Console.Out.WriteLine(item.Title);
                Console.Out.WriteLine(item.Modified);
                Console.Out.WriteLine(item.ModifiedBy.User.LoginName);
                Console.Out.WriteLine(item.Created);
                Console.Out.WriteLine(item.CreatedBy.User.LoginName);
           }
     }
}

Last edited Nov 1, 2013 at 10:18 AM by cverhelst, version 1