Showing posts with label sand boxed code. Show all posts
Showing posts with label sand boxed code. Show all posts

Tuesday, March 5, 2013

SharePoint 2010 : Query using SPMetal entity

In SharePoint 2010, we can use LINQ queries to search data within SharePoint site. In previous SharePoint versions, I tend to use CAML queries instead, which is an efficient way to look for items. However, LINQ queries are faster and simpler to implement.
For more information on LINQ queries: follow this URL
For using LINQ within SharePoint, Microsoft has provided a tool named SPMetal.exe which resides in the 14 hive folder. This tool generates an entity class which we can add to our Visual Studio solution to get intellisense and use the entity classes for fetching data from SharePoint site.

Using SPMetal.exe

Go to command prompt and navigate to
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\bin
  • Type SPMetal.exe /web:http://sharepointsite /code:C:\MyLINQEntity.cs

Now if you open the file, we just created, you can see all the lists, libraries have their classes with content types mentioned. It might happen that some custom content types are replaces with Item which is by default behaviour; you can modify the content types for the actual ones (you will get it in the intellisense).

Now that you add your .cs file to your Visual Studio project, you can use it for fetching items in SharePoint site.

using (PropertiesEntityDataContext context = new PropertiesEntityDataContext(SPSiteAddress))
{
//creating object from the Entity
EntityList<legalcasedocumentset> documentSet = context.GetList<legalcasedocumentset>(libName);
var first3Items = from item in documentSet.ScopeToFolder(folderURL, true)
where item.Name == docSetName
select item;

Friday, February 8, 2013

SharePoint 2010 : No available sandboxed code execution server could be found

This might cause your sand boxed cause to seize and not perform their regular functions.

You need to re-start(Stop and Start again) the Microsoft SharePoint Foundation Sand boxed Code Service from services on server. You might see that it is already started, still just Stop the service and Start again.

Central Administration > System Settings > Servers > Manage Services on server > Start the Microsoft SharePoint Foundation Sand boxed Code Service

Try this at first instance which might resolve your error. If this doesn't work, you can email me and we can work it out together.