none
why doesn't SPMetal generate Publishing Schedule columns?

    Question

  • Happy 2011 experts,,,

    I have a sharepoint 2010 publishing site that I use SPMetal to generate classes to. The problem is some fields doesn't get generated like:

    PublishingStartDate and PublishingEndDate even though I tried using IncludeHiddenColumns and IncludeHiddenContentTypes parameters with no success.

    Any clue?


    Search and Destroy,,,
    Saturday, January 01, 2011 5:24 PM

Answers

All replies

  • I assume you had a look at http://msdn.microsoft.com/en-us/library/ee535056.aspx and the last note about xml structure. If not, you may fin the answer there.
    AK
    Saturday, January 01, 2011 6:45 PM
  • At this moment SPMetal includes only fields based on Field Types available with SharePoint Foundation. Since the columns you mentioned ship with SharePoint Server they are not by default included in classes generated by SPMetal. The good news is, that classes generated by SPMetal are partial so you can your own fields yourself.
    w: http://blog.mastykarz.nl | t: @waldekm | c: http://mavention.codeplex.com | c: http://mavention.nl
    Saturday, January 01, 2011 10:44 PM
  • I honestly appreciate your answer Mr Waldek, but how we were supposed to know that, I mean I've been searching and trying for a while but no Microsoft resource said anything about that.

     

    Thank you very much, btw I'm subscribed to your blog already it's really interesting keep it up :)


    Search and Destroy,,,
    Sunday, January 02, 2011 6:54 AM
  • using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint.Linq;
    using Microsoft.SharePoint;
    
    
    public partial class MyClass : Page, ICustomMapping
    {
        const string SchedulingStartDateInternalName = "PublishingStartDate";
    
        private System.Nullable<system.datetime> _schedulingStartDate;
    
        public System.Nullable<system.datetime> SchedulingStartDate
        {
            get
            {
                return this._schedulingStartDate;
            }
            set
            {
                if ((value != this._schedulingStartDate))
                {
                    this.OnPropertyChanging("SchedulingStartDate", this._schedulingStartDate);
                    this._schedulingStartDate = value;
                    this.OnPropertyChanged("SchedulingStartDate");
                }
            }
        }
    
        [CustomMapping(Columns = new String[] { SchedulingStartDateInternalName })]
        public void MapFrom(object listItem)
        {
            SPListItem item = listItem as SPListItem;
            if (item != null)
                this.SchedulingStartDate = item[SchedulingStartDateInternalName] as DateTime?;
        }
    
        public void MapTo(object listItem)
        {
            SPListItem item = listItem as SPListItem;
            item[SchedulingStartDateInternalName] = this.SchedulingStartDate;
        }
    
    
        public void Resolve(RefreshMode mode, object originalListItem, object databaseListItem)
        {
            SPListItem originalItem = (SPListItem)originalListItem;
            SPListItem databaseItem = (SPListItem)databaseListItem;
    
            DateTime? originalStartDateValue = originalItem[SchedulingStartDateInternalName] as DateTime?;
            DateTime? databaseStartDateValue = databaseItem[SchedulingStartDateInternalName] as DateTime?;
    
    
            if (mode == RefreshMode.OverwriteCurrentValues)
            {
                this.SchedulingStartDate = databaseStartDateValue;
            }
            else if (mode == RefreshMode.KeepCurrentValues)
            {
                databaseItem[SchedulingStartDateInternalName] = this.SchedulingStartDate;
            }
            else if (mode == RefreshMode.KeepChanges)
            {
                if (this.SchedulingStartDate != originalStartDateValue)
                    databaseItem[SchedulingStartDateInternalName] = this.SchedulingStartDate;
                else if (this.SchedulingStartDate == originalStartDateValue && this.SchedulingStartDate != databaseStartDateValue)
                    this.SchedulingStartDate = databaseStartDateValue;
            }
        }
    }</system.datetime></system.datetime>


    • Edited by Ethand Friday, February 10, 2012 9:47 PM
    Friday, February 10, 2012 9:44 PM
  • I admit it's hard just to know these things, but the great thing is that you asked.

    Thank you for your feedback and subscribing to my blog: much appreciated!


    w: http://blog.mastykarz.nl | t: @waldekm | c: http://mavention.codeplex.com | c: http://mavention.nl

    Saturday, February 11, 2012 9:49 AM