Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPMetal not generating classes with proper custom types. Defaulting for everything to 'Item'

I'm trying to generate classes using SPMetal to make use of SPLINQ. Generating the code is no problem, except the properties are not typed properly.

This is fraction of the code:

[Microsoft.SharePoint.Linq.ListAttribute(Name="Actual Purchase Orders")]
public Microsoft.SharePoint.Linq.EntityList<Item> ActualPurchaseOrders {
    get {
        return this.GetList<Item>("Actual Purchase Orders");
    }
}

As you can see the return type is defined as Microsoft.SharePoint.Linq.EntityList<Item>. While I'd like it to be Microsoft.SharePoint.Linq.EntityList<ActualPurchaseOrder>. This is the same case for all lists and all properties for all list. The only properly typed properties are the sharepoint internal ones like Link, Document, HelpFilesDocument, etc.

I checked all list settings, like content types etc. No luck.

Is it just a bug in my 14.0.4763.1000 version?

Any help appreciated. Cheers.

like image 775
Sam7 Avatar asked Nov 04 '22 21:11

Sam7


1 Answers

If ActualPurchaseOrder is not a custom contenttype which you have defined, than you will have to override the spmetal tool with a parameters xml file. (http://msdn.microsoft.com/en-us/library/ee535056.aspx)

I think this blogpost will give you some good steps in the right direction: http://socialsp.com/2009/12/11/having-fun-with-the-new-linq-to-sharepoint-on-sharepoint-2010-sp2010/

like image 190
ChristiaanV Avatar answered Nov 09 '22 15:11

ChristiaanV