示例#1
0
文件: Caml.cs 项目: acharal/spsync
 public static Field GetCamlField(this XElement xmlNode)
 {
     Field field = new Field();
     field.Name = xmlNode.Attribute("Name").Value;
     field.IsRequired  = xmlNode.AttributeBoolOrFalse("Required");
     field.IsReadOnly = xmlNode.AttributeBoolOrFalse("ReadOnly");
     field.IsHidden = xmlNode.AttributeBoolOrFalse("Hidden");
     field.FieldType   = xmlNode.Attribute("Type").Value;
     field.DisplayName = xmlNode.Attribute("DisplayName").Value;
     field.IsIndexed = xmlNode.AttributeBoolOrFalse("Indexed");
     field.List = xmlNode.AttributeValueOrDefault("List");
     field.IsPrimaryKey = xmlNode.AttributeBoolOrFalse("PrimaryKey");
     return field;
 }
示例#2
0
        /// <summary>
        /// Sets the properties of the column according to the properties of a sharepoint field
        /// </summary>
        /// <param name="column">the DataColumn object to change</param>
        /// <param name="field">the Sharepoint Field</param>
        protected void MapFromFieldToColumn(DataColumn column, Field field)
        {
            int num = this.TypeMappings.IndexOfFieldType(field.FieldType);
            TypeMapping typeMapping;

            if (num > -1)
            {
                typeMapping = this.TypeMappings[num];
            }
            else if (this.TypeMappings.DefaultMapping != null)
            {
                typeMapping = this.TypeMappings.DefaultMapping;
            }
            else
            {
                throw new NotImplementedException("there is no default type mapping");
            }

            column.ColumnName = field.Name;
            column.Caption    = field.DisplayName;
            column.DataType = typeMapping.Type;

            SetDataColumnExtendedProperty(column, "DataTypeName", typeMapping.SqlType);

            if (typeMapping.SqlLength != null)
               SetDataColumnExtendedProperty(column, "ColumnLength", typeMapping.SqlLength);

            if (column.ColumnName == this.RowGuidColumn)
                SetDataColumnExtendedProperty(column, "RowGuidCol", true);
        }