Project Description

Traditionally SharePoint projects are hard to unit test, use weak typing, and require complicated XML to query for data. Sporm (TM) is specifically designed to simplify unit testing, enable strongly typed objects, and support LINQ access to SharePoint objects.

Benefits

  • Simplifies unit testing - by hiding unmockable objects like SPWeb and SPListItem
  • Enables strongly typed code - by generating classes and properties for lists and content types
  • Eliminates the need for ugly loosly typed CAML queries - by acting as a LINQ provider to your lists

Unlike Other SharePoint Tools (e.g. LINQ to SharePoint)

  • Natively supports strongly typed create, read, update, and delete operations
  • Allows multiple content types per list
  • Supports modifying the generated code through the use of templates

External Sites Talking About sporm

Quick Examples

These examples assume you have a content type called "PersonContentType" and a list called "PersonList". The content type has a FirstName and a LastName.

Getting list items

This will get all "PersonContentType" items from the "PersonList" where there first name starts with the letter 'B'.
  using(MySPDataContext ctx = new MySPDataContext(site)) {
    var peopleWhosNameStartsWithB = ctx.PersonList.OfType<PersonContentType>().Where(i => i.FirstName.StartsWith("B"));
    // ... do something ...
  }

Saving a list item

This will create a new person and save it to the the "PersonList".
  using(MySPDataContext ctx = new MySPDataContext(site)) {
    var person = new PersonContentType {
      FirstName = "John",
      LastName = "Doe"
    };
    ctx.Save<PersonList>(person);
  }

Updating a list item

This will get the list item with id 1 from the "PersonList" and change the first name to "Joe" and then save it.
  using(MySPDataContext ctx = new MySPDataContext(site)) {
    var personToUpdate = ctx.PersonList.OfType<PersonContentType>().First(i => i.ID == 1);
    personToUpdate.FirstName = "Joe";
    ctx.Update(personToUpdate);
  }

Deleting a list item

This will delete the list item with the id 1.
  using(MySPDataContext ctx = new MySPDataContext(site)) {
    var personToDelete = ctx.PersonList.OfType<PersonContentType>().First(i => i.ID == 1);
    ctx.Delete(personToDelete);
  }

Last edited Sep 14, 2009 at 2:22 PM by lprichar, version 14