Pages

Tuesday, August 17, 2010

Linq with SharePoint 2010 - Part I

Today I have decided to start working on my web part that will be interacting with SharePoint 2010 through LINQ, after spending a few R&D through the web, I have started my development of Visual Web Part with SharePoint LINQ (Of course, using Visual Studio 2010!).

Before that, let me create a list named "Quote of the Week" which a few columns.

1. Start Visual Studio 2010 (Of course!)

2. Create a Visual Web Part Project, which will automatically generate the files required.

3. Now, i need to really get my hands on the SharePoint Linq experience, thus, i will be going to my web part folder, and run the SPMetal.exe command from your command prompt.

4. A class file will be generated, basically this class file will be wrapping all your lists definition, so that you can access STRONG TYPED list objects (Yeah!!!)



5. Add this class file to your project NOW!

6. Wait, i need a field, internal field for created date, but, it is not in my generated class. So, what i will do is to replicate a property (It will returned the field value based on the properties you set for the list!).


6. Now, i have my object models for SharePoint Linq done, let's put this into practical, note the following code snippet. This is the page load event that query SharePoint list, using Linq of course!

NOTE: This piece of code query the Quote of the Week list, search for quote items where Start Date <> and End Date > Today, and it will be sorted by the created date, in descending order.

7. Yes! My Quote of the Week web part is now DONE!

Easy? Now, let's rock-and-roll NOW!

Note : If you are changing the namespace and class name, you need to change the Safe Control registration, see the following URL,

http://www.andrewconnell.com/blog/archive/2010/07/01/renaming-web-parts-for-sharepoint-2010-with-visual-studio-2010.aspx

Sunday, August 15, 2010

SharePoint 2010 Master Page

When it come to styling and changing the UI for SharePoint, you can't run away from Master Page, now, in 2010, you will still be changing and working with Master Page, from your SharePoint Designer 2010.

Few things to be aware of when working with SharePoint 2010 master page,

1. When you have a team site, please turn on your Publishing feature so you can then pick and choose the master page to apply to your site.

2. Simplest to start off with is really to start off with the Starter Master Page by Randy Drisgill, this master page really give you a quick and clean starts by removing all unnecessary html elements, which is quite irritating if you were to reposition the SharePoint controls.

3. In the Starter Master Page, change the CSS registration control to map to your CSS file (Of course, store it in your Style Library).

4. Start your IE8, use the Developer Tool to start picking up elements and change the CSS classes to your preference! You may refer the following URL for the list of CSS classes used in SharePoint,

Have Fun with your Master Page, i will post one of my "test drive" in the later post!

Thursday, August 12, 2010

Linq with Sharepoint

Doing a few round of testing on Linq and Sharepoint with my tech lead, and here is the outcome of our testing, the joining between two lists with simple Linq syntax was extremely straight forward, but, the result was just awesome!

The following is the code snippet,


If you are developing some custom applications which stored data in multiple Sharepoint lists, this piece of code is gonna save your days!

I will be posting the sample lists and results achievable in a later post.

Microsoft Innovation Day - 6 August 2010

For those who attended the Microsoft Innovation Day, Malaysia, @6 August 2010, if you need the slide that i have presented, feel free to download from my sky drive, or view online at the following link,


Happy Reporting!

Tuesday, August 10, 2010

PowerPivot Demo is ONLINE AGAIN!

For those who are interested, PowerPivot online demo is running again!


Happy PowerPivot!


PowerPivot for SharePoint Installation

My first PowerPivot for SharePoint installation was done last year December, that was really far back where SQL Server 2008 R2 was still in CTP.

Last month, i have to setup the PowerPivot for my SharePoint 2010 RTM instance, in preparing for some demos and events.

My first attempt was really a smooth start, New Installation on Existing Farm brought me to the following screen, where i am happy to see that!

Now, my excitement does not last long when i start hitting some "Generic Error" that really cracking my head (First time, i did not capture the error log).

Went ahead and check out with my colleagues, we are suspecting the Claim to Windows Token Services was disabled, without second thought, we went ahead to enable the service, and restart the installation (No effect on my existing instance, thanks to Hyper-V snapshot).

Guess what, the installation is still failed! This time around, we are getting a different error message,

Could not load file or assembly 'Microsoft.AnalysisServices.SharePoint.Integration'.....or one of its dependencies. The system cannot find the file specified.

Arghh... what's wrong with my SharePoint, am i doing anything wrong? Man, what does it has to do with Analysis Services?

I am giving this up, and now is time to Bing around for answer, well, there are a few article out there that mentioned about the c2wts config, but what helped me was the article from PowerPivotGeek. (You guys ROCK!)

The explanation as following: -

In SQL Server 2008 R2, the msmdsrv.exe process (which is the SSAS engine) includes a reference to the PowerPivot SharePoint integration dll (as do other components). Since the normal SSAS installation does not include the SharePoint integration dll, the registration marks the .NET assembly cache as failed. Later on, when you install PowerPivot, we copy the SharePoint integration dll to the right place, but the .NET assembly cache has already been marked failed from the previous SSAS installation and .NET does not attempt to load it (and you get the error message above).

So i should be setting up at the following sequence?

1. Microsoft SQL Server 2008 R2 (Only Database Engine)
2. Microsoft SharePoint 2010
3. PowerPivot for SharePoint
4. Analysis Services and etc.

Is that correct? Anyone?