Omicron Llama

Coding all day, every day.

c#

A Very Damned-Useful Extension Method

Trying never to use SPList.Items (due to Best Practice), yet needing to grab some items from a list quite often? Here’s an extension method which I use a fair bit.

You can then use regular LINQ queries to get the item or items you need against the object returned by this, for example:

[…]

Creating Custom PerformancePoint Reports in C#

(Concepts here are discussed around SharePoint 2010 but should equally be applicable to SharePoint 2013. All concepts here apply only to full-trust farm solutions, and cannot be done at all with Sandboxed solutions or with the App model)Occasionally you might give given the requirement (as a developer) to provide the ability to insert a chart […]

Get All PerformancePoint Filter Value selections in a Site Collection For the Current User

Here’s some code to get all PerformancePoint filter selections for the current user in a web site. This is a fairly straightforward operation. First you need a collection of strings, each of which is the URL to a PerformancePoint Filter stored in SharePoint. In this code snippet I use SPSiteDataQuery (in the DiscoverFilterUrls() method). You […]

ASP.NET Modules – reading InputStream with StreamReader

If, like me, if you’ve gotten into habit of wrapping most things that implement IDisposable in a ‘using’ statement, then you’ll be wondering why the hell you can’t read from the Requests’s InputStream property using a StreamReader without your request pipeline breaking. Turns out, that you mustn’t dispose of the StreamReader immediately, as when you […]

SharePoint Development – What to Learn?

I thought I’d jot down a few things which I believe fresh SharePoint developers need to know when they’re confronted with the daunting task of developing something for SharePoint for the first time. SharePoint development has a massively steep learning curve. It literally takes years to get good at not only developing solutions in SharePoint, […]

Resetting Item Level Permissions Programmatically

As part of my series of blog posts on item level permissions, I thought I’d post a quick note on “resetting” item-level permissions on a list. This can be done using the method SPListItem.ResetRoleInheritance() on the list item in question. This will reset any item level permissions on this item to inherit from the List […]

Reordering Content Types Programmatically

After this question was asked on SharePoint Stack Exchange, I thought I’d share my method of re-ordering content types in a list. Note: this isn’t the only method of doing this, see the thread on SPSE to see more (particularly the UniqueContentTypeOrder property).

SPList.Items versus the SPQuery

So you’ve embarked on writing a bit of code that must enumerate a SharePoint List’s Items one by one and do some stuff with them. You’ve (at some point) came across the Best Practices page on MSDN on Handling Large Folders and Lists, and seen that using SPList.Items is bad. It’s bad because you could […]

Programmatically Update a Content Type

Here’s a straight forward one. For some reason (don’t ask) I had to update a content type in a Feature Receiver (I would have preferred to have created a new content type and inherit) by adding a new field to it. Here’s the code, purely for my personal reference but open in case other people […]

Previous Posts