SharePoint 2010: Como generar un proxy LINQ To SharePoint con ciertas listas y tipos de contenido!

Cuando usamos la herramienta de línea de comandos SPMetal para generar un proxy de LINQ To SharePoint, normalmente generamos una serie de entidades que representan todas las listas y bibliotecas disponibles en el sitio. Ahora bien, puede ser interesante generar un proxy sólo con aquellas listas y bibliotecas que necesitemos…y esto es posible gracias al parámetro “parameters” de SPMetal que permite especificar en un archivo XML que listas o bibliotecas tiene que incluir el proxy a generar. La sintaxis a usar sería la siguiente:

   1: spmetal /web:http://<mySharePointSite> /namespace:SPLINQSmallProxy /parameters:LINQToSPProxyConfiguration.xml /code::SPLINQSmallProxy.cs

Y el contenido del archivo XML que define como crear el Proxy el siguiente:

   1: <?xml version="1.0" encoding="utf-8"?>

   2: <Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">

   3:     <List Name="Tareas">

   4:         <ContentType Name="Tarea" Class="Tarea" />        

   5:     </List>

   6:     <List Name="Empresas" />

   7:     <ExcludeOtherLists />

   8: </Web>

Como vemos en el archivo de configuración:

  • Estamos incluyendo en el proxy generado la lista Tareas y el tipo de contenido Tarea.
  • Estamos incluyendo la lista Empresa.
  • Estamos excluyendo el resto de listas.

De esta forma, el proxy generado sería el siguiente:

   1: //------------------------------------------------------------------------------

   2: // <auto-generated>

   3: //     This code was generated by a tool.

   4: //     Runtime Version:2.0.50727.4952

   5: //

   6: //     Changes to this file may cause incorrect behavior and will be lost if

   7: //     the code is regenerated.

   8: // </auto-generated>

   9: //------------------------------------------------------------------------------

  10:  

  11: namespace SPLINQSmallProxy {

  12:     using System;

  13:     

  14:     

  15:     internal partial class SPLINQSmallProxySiteDataContext : Microsoft.SharePoint.Linq.DataContext {

  16:         

  17:         #region Extensibility Method Definitions

  18:         partial void OnCreated();

  19:         #endregion

  20:         

  21:         public SPLINQSmallProxySiteDataContext(string requestUrl) : 

  22:                 base(requestUrl) {

  23:             this.OnCreated();

  24:         }

  25:         

  26:         [Microsoft.SharePoint.Linq.ListAttribute(Name="Empresas")]

  27:         public Microsoft.SharePoint.Linq.EntityList<EmpresasItem> Empresas {

  28:             get {

  29:                 return this.GetList<EmpresasItem>("Empresas");

  30:             }

  31:         }

  32:         

  33:         /// <summary>

  34:         /// Utilice la lista de tareas para controlar el trabajo que usted o su grupo tiene que realizar.

  35:         /// </summary>

  36:         [Microsoft.SharePoint.Linq.ListAttribute(Name="Tareas")]

  37:         public Microsoft.SharePoint.Linq.EntityList<Item> Tareas {

  38:             get {

  39:                 return this.GetList<Item>("Tareas");

  40:             }

  41:         }

  42:     }

  43:     

  44:     /// <summary>

  45:     /// Create a new list item.

  46:     /// </summary>

  47:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Item", Id="0x01")]

  48:     [Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(EmpresasItem))]

  49:     [Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(Folder))]

  50:     [Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(Task))]

  51:     internal partial class Item : Microsoft.SharePoint.Linq.ITrackEntityState, Microsoft.SharePoint.Linq.ITrackOriginalValues, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging {

  52:         

  53:         private System.Nullable<int> _id;

  54:         

  55:         private System.Nullable<int> _version;

  56:         

  57:         private string _path;

  58:         

  59:         private Microsoft.SharePoint.Linq.EntityState _entityState;

  60:         

  61:         private System.Collections.Generic.IDictionary<string, object> _originalValues;

  62:         

  63:         private string _title;

  64:         

  65:         #region Extensibility Method Definitions

  66:         partial void OnLoaded();

  67:         partial void OnValidate();

  68:         partial void OnCreated();

  69:         #endregion

  70:  

  71:         Microsoft.SharePoint.Linq.EntityState Microsoft.SharePoint.Linq.ITrackEntityState.EntityState {

  72:             get {

  73:                 return this._entityState;

  74:             }

  75:             set {

  76:                 if ((value != this._entityState)) {

  77:                     this._entityState = value;

  78:                 }

  79:             }

  80:         }

  81:  

  82:         System.Collections.Generic.IDictionary<string, object> Microsoft.SharePoint.Linq.ITrackOriginalValues.OriginalValues {

  83:             get {

  84:                 if ((null == this._originalValues)) {

  85:                     this._originalValues = new System.Collections.Generic.Dictionary<string, object>();

  86:                 }

  87:                 return this._originalValues;

  88:             }

  89:         }

  90:         

  91:         public Item() {

  92:             this.OnCreated();

  93:         }

  94:         

  95:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="ID", Storage="_id", ReadOnly=true, FieldType="Counter")]

  96:         public System.Nullable<int> Id {

  97:             get {

  98:                 return this._id;

  99:             }

 100:             set {

 101:                 if ((value != this._id)) {

 102:                     this.OnPropertyChanging("Id", this._id);

 103:                     this._id = value;

 104:                     this.OnPropertyChanged("Id");

 105:                 }

 106:             }

 107:         }

 108:         

 109:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="owshiddenversion", Storage="_version", ReadOnly=true, FieldType="Integer")]

 110:         public System.Nullable<int> Version {

 111:             get {

 112:                 return this._version;

 113:             }

 114:             set {

 115:                 if ((value != this._version)) {

 116:                     this.OnPropertyChanging("Version", this._version);

 117:                     this._version = value;

 118:                     this.OnPropertyChanged("Version");

 119:                 }

 120:             }

 121:         }

 122:         

 123:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="FileDirRef", Storage="_path", ReadOnly=true, FieldType="Lookup", IsLookupValue=true)]

 124:         public string Path {

 125:             get {

 126:                 return this._path;

 127:             }

 128:             set {

 129:                 if ((value != this._path)) {

 130:                     this.OnPropertyChanging("Path", this._path);

 131:                     this._path = value;

 132:                     this.OnPropertyChanged("Path");

 133:                 }

 134:             }

 135:         }

 136:         

 137:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Title", Storage="_title", Required=true, FieldType="Text")]

 138:         public virtual string Title {

 139:             get {

 140:                 return this._title;

 141:             }

 142:             set {

 143:                 if ((value != this._title)) {

 144:                     this.OnPropertyChanging("Title", this._title);

 145:                     this._title = value;

 146:                     this.OnPropertyChanged("Title");

 147:                 }

 148:             }

 149:         }

 150:         

 151:         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

 152:         

 153:         public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging;

 154:         

 155:         protected virtual void OnPropertyChanged(string propertyName) {

 156:             if ((null != this.PropertyChanged)) {

 157:                 this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));

 158:             }

 159:         }

 160:         

 161:         protected virtual void OnPropertyChanging(string propertyName, object value) {

 162:             if ((null == this._originalValues)) {

 163:                 this._originalValues = new System.Collections.Generic.Dictionary<string, object>();

 164:             }

 165:             if ((false == this._originalValues.ContainsKey(propertyName))) {

 166:                 this._originalValues.Add(propertyName, value);

 167:             }

 168:             if ((null != this.PropertyChanging)) {

 169:                 this.PropertyChanging(this, new System.ComponentModel.PropertyChangingEventArgs(propertyName));

 170:             }

 171:         }

 172:     }

 173:     

 174:     /// <summary>

 175:     /// Create a new folder.

 176:     /// </summary>

 177:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Folder", Id="0x0120")]

 178:     [Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(SummaryTask))]

 179:     internal partial class Folder : Item {

 180:         

 181:         private string _name;

 182:         

 183:         private System.Nullable<int> _itemChildCountId;

 184:         

 185:         private string _itemChildCountItemChildCount;

 186:         

 187:         private System.Nullable<int> _folderChildCountId;

 188:         

 189:         private string _folderChildCountFolderChildCount;

 190:         

 191:         #region Extensibility Method Definitions

 192:         partial void OnLoaded();

 193:         partial void OnValidate();

 194:         partial void OnCreated();

 195:         #endregion

 196:         

 197:         public Folder() {

 198:             this.OnCreated();

 199:         }

 200:         

 201:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="FileLeafRef", Storage="_name", Required=true, FieldType="File")]

 202:         public string Name {

 203:             get {

 204:                 return this._name;

 205:             }

 206:             set {

 207:                 if ((value != this._name)) {

 208:                     this.OnPropertyChanging("Name", this._name);

 209:                     this._name = value;

 210:                     this.OnPropertyChanged("Name");

 211:                 }

 212:             }

 213:         }

 214:         

 215:         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

 216:         [Microsoft.SharePoint.Linq.RemovedColumnAttribute()]

 217:         public override string Title {

 218:             get {

 219:                 throw new System.InvalidOperationException("Field Title was removed from content type Folder.");

 220:             }

 221:             set {

 222:                 throw new System.InvalidOperationException("Field Title was removed from content type Folder.");

 223:             }

 224:         }

 225:         

 226:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="ItemChildCount", Storage="_itemChildCountId", ReadOnly=true, FieldType="Lookup", IsLookupId=true)]

 227:         public System.Nullable<int> ItemChildCountId {

 228:             get {

 229:                 return this._itemChildCountId;

 230:             }

 231:             set {

 232:                 if ((value != this._itemChildCountId)) {

 233:                     this.OnPropertyChanging("ItemChildCountId", this._itemChildCountId);

 234:                     this._itemChildCountId = value;

 235:                     this.OnPropertyChanged("ItemChildCountId");

 236:                 }

 237:             }

 238:         }

 239:         

 240:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="ItemChildCount", Storage="_itemChildCountItemChildCount", ReadOnly=true, FieldType="Lookup", IsLookupValue=true)]

 241:         public string ItemChildCountItemChildCount {

 242:             get {

 243:                 return this._itemChildCountItemChildCount;

 244:             }

 245:             set {

 246:                 if ((value != this._itemChildCountItemChildCount)) {

 247:                     this.OnPropertyChanging("ItemChildCountItemChildCount", this._itemChildCountItemChildCount);

 248:                     this._itemChildCountItemChildCount = value;

 249:                     this.OnPropertyChanged("ItemChildCountItemChildCount");

 250:                 }

 251:             }

 252:         }

 253:         

 254:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="FolderChildCount", Storage="_folderChildCountId", ReadOnly=true, FieldType="Lookup", IsLookupId=true)]

 255:         public System.Nullable<int> FolderChildCountId {

 256:             get {

 257:                 return this._folderChildCountId;

 258:             }

 259:             set {

 260:                 if ((value != this._folderChildCountId)) {

 261:                     this.OnPropertyChanging("FolderChildCountId", this._folderChildCountId);

 262:                     this._folderChildCountId = value;

 263:                     this.OnPropertyChanged("FolderChildCountId");

 264:                 }

 265:             }

 266:         }

 267:         

 268:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="FolderChildCount", Storage="_folderChildCountFolderChildCount", ReadOnly=true, FieldType="Lookup", IsLookupValue=true)]

 269:         public string FolderChildCountFolderChildCount {

 270:             get {

 271:                 return this._folderChildCountFolderChildCount;

 272:             }

 273:             set {

 274:                 if ((value != this._folderChildCountFolderChildCount)) {

 275:                     this.OnPropertyChanging("FolderChildCountFolderChildCount", this._folderChildCountFolderChildCount);

 276:                     this._folderChildCountFolderChildCount = value;

 277:                     this.OnPropertyChanged("FolderChildCountFolderChildCount");

 278:                 }

 279:             }

 280:         }

 281:     }

 282:     

 283:     /// <summary>

 284:     /// Track a work item that you or your team needs to complete.

 285:     /// </summary>

 286:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Task", Id="0x0108")]

 287:     [Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(TareasTask))]

 288:     internal partial class Task : Item {

 289:         

 290:         private System.Nullable<double> _complete;

 291:         

 292:         private string _body;

 293:         

 294:         private System.Nullable<System.DateTime> _startDate;

 295:         

 296:         protected System.Nullable<System.DateTime> _dueDate;

 297:         

 298:         private System.Nullable<Priority> _priority;

 299:         

 300:         protected System.Nullable<TaskStatus> _taskStatus;

 301:         

 302:         private System.Nullable<int> _assignedToId;

 303:         

 304:         private string _assignedTo;

 305:         

 306:         #region Extensibility Method Definitions

 307:         partial void OnLoaded();

 308:         partial void OnValidate();

 309:         partial void OnCreated();

 310:         #endregion

 311:         

 312:         public Task() {

 313:             this.OnCreated();

 314:         }

 315:         

 316:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="PercentComplete", Storage="_complete", FieldType="Number")]

 317:         public System.Nullable<double> Complete {

 318:             get {

 319:                 return this._complete;

 320:             }

 321:             set {

 322:                 if ((value != this._complete)) {

 323:                     this.OnPropertyChanging("Complete", this._complete);

 324:                     this._complete = value;

 325:                     this.OnPropertyChanged("Complete");

 326:                 }

 327:             }

 328:         }

 329:         

 330:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Body", Storage="_body", FieldType="Note")]

 331:         public string Body {

 332:             get {

 333:                 return this._body;

 334:             }

 335:             set {

 336:                 if ((value != this._body)) {

 337:                     this.OnPropertyChanging("Body", this._body);

 338:                     this._body = value;

 339:                     this.OnPropertyChanged("Body");

 340:                 }

 341:             }

 342:         }

 343:         

 344:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="StartDate", Storage="_startDate", FieldType="DateTime")]

 345:         public System.Nullable<System.DateTime> StartDate {

 346:             get {

 347:                 return this._startDate;

 348:             }

 349:             set {

 350:                 if ((value != this._startDate)) {

 351:                     this.OnPropertyChanging("StartDate", this._startDate);

 352:                     this._startDate = value;

 353:                     this.OnPropertyChanged("StartDate");

 354:                 }

 355:             }

 356:         }

 357:         

 358:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="TaskDueDate", Storage="_dueDate", FieldType="DateTime")]

 359:         public virtual System.Nullable<System.DateTime> DueDate {

 360:             get {

 361:                 return this._dueDate;

 362:             }

 363:             set {

 364:                 if ((value != this._dueDate)) {

 365:                     this.OnPropertyChanging("DueDate", this._dueDate);

 366:                     this._dueDate = value;

 367:                     this.OnPropertyChanged("DueDate");

 368:                 }

 369:             }

 370:         }

 371:         

 372:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Priority", Storage="_priority", FieldType="Choice")]

 373:         public System.Nullable<Priority> Priority {

 374:             get {

 375:                 return this._priority;

 376:             }

 377:             set {

 378:                 if ((value != this._priority)) {

 379:                     this.OnPropertyChanging("Priority", this._priority);

 380:                     this._priority = value;

 381:                     this.OnPropertyChanged("Priority");

 382:                 }

 383:             }

 384:         }

 385:         

 386:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="TaskStatus", Storage="_taskStatus", FieldType="Choice")]

 387:         public virtual System.Nullable<TaskStatus> TaskStatus {

 388:             get {

 389:                 return this._taskStatus;

 390:             }

 391:             set {

 392:                 if ((value != this._taskStatus)) {

 393:                     this.OnPropertyChanging("TaskStatus", this._taskStatus);

 394:                     this._taskStatus = value;

 395:                     this.OnPropertyChanged("TaskStatus");

 396:                 }

 397:             }

 398:         }

 399:         

 400:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedToId", FieldType="User", IsLookupId=true)]

 401:         public System.Nullable<int> AssignedToId {

 402:             get {

 403:                 return this._assignedToId;

 404:             }

 405:             set {

 406:                 if ((value != this._assignedToId)) {

 407:                     this.OnPropertyChanging("AssignedToId", this._assignedToId);

 408:                     this._assignedToId = value;

 409:                     this.OnPropertyChanged("AssignedToId");

 410:                 }

 411:             }

 412:         }

 413:         

 414:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedTo", ReadOnly=true, FieldType="User", IsLookupValue=true)]

 415:         public string AssignedTo {

 416:             get {

 417:                 return this._assignedTo;

 418:             }

 419:             set {

 420:                 if ((value != this._assignedTo)) {

 421:                     this.OnPropertyChanging("AssignedTo", this._assignedTo);

 422:                     this._assignedTo = value;

 423:                     this.OnPropertyChanged("AssignedTo");

 424:                 }

 425:             }

 426:         }

 427:     }

 428:     

 429:     /// <summary>

 430:     /// Group and describe related tasks that you or your team needs to complete.

 431:     /// </summary>

 432:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Summary Task", Id="0x012004")]

 433:     [Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(TareasSummaryTask))]

 434:     internal partial class SummaryTask : Folder {

 435:         

 436:         private System.Nullable<double> _complete;

 437:         

 438:         private string _body;

 439:         

 440:         private System.Nullable<System.DateTime> _startDate;

 441:         

 442:         protected System.Nullable<System.DateTime> _dueDate;

 443:         

 444:         private System.Nullable<Priority> _priority;

 445:         

 446:         protected System.Nullable<TaskStatus> _taskStatus;

 447:         

 448:         private System.Nullable<int> _assignedToId;

 449:         

 450:         private string _assignedTo;

 451:         

 452:         #region Extensibility Method Definitions

 453:         partial void OnLoaded();

 454:         partial void OnValidate();

 455:         partial void OnCreated();

 456:         #endregion

 457:         

 458:         public SummaryTask() {

 459:             this.OnCreated();

 460:         }

 461:         

 462:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="PercentComplete", Storage="_complete", FieldType="Number")]

 463:         public System.Nullable<double> Complete {

 464:             get {

 465:                 return this._complete;

 466:             }

 467:             set {

 468:                 if ((value != this._complete)) {

 469:                     this.OnPropertyChanging("Complete", this._complete);

 470:                     this._complete = value;

 471:                     this.OnPropertyChanged("Complete");

 472:                 }

 473:             }

 474:         }

 475:         

 476:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Body", Storage="_body", FieldType="Note")]

 477:         public string Body {

 478:             get {

 479:                 return this._body;

 480:             }

 481:             set {

 482:                 if ((value != this._body)) {

 483:                     this.OnPropertyChanging("Body", this._body);

 484:                     this._body = value;

 485:                     this.OnPropertyChanged("Body");

 486:                 }

 487:             }

 488:         }

 489:         

 490:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="StartDate", Storage="_startDate", FieldType="DateTime")]

 491:         public System.Nullable<System.DateTime> StartDate {

 492:             get {

 493:                 return this._startDate;

 494:             }

 495:             set {

 496:                 if ((value != this._startDate)) {

 497:                     this.OnPropertyChanging("StartDate", this._startDate);

 498:                     this._startDate = value;

 499:                     this.OnPropertyChanged("StartDate");

 500:                 }

 501:             }

 502:         }

 503:         

 504:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="TaskDueDate", Storage="_dueDate", FieldType="DateTime")]

 505:         public virtual System.Nullable<System.DateTime> DueDate {

 506:             get {

 507:                 return this._dueDate;

 508:             }

 509:             set {

 510:                 if ((value != this._dueDate)) {

 511:                     this.OnPropertyChanging("DueDate", this._dueDate);

 512:                     this._dueDate = value;

 513:                     this.OnPropertyChanged("DueDate");

 514:                 }

 515:             }

 516:         }

 517:         

 518:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Priority", Storage="_priority", FieldType="Choice")]

 519:         public System.Nullable<Priority> Priority {

 520:             get {

 521:                 return this._priority;

 522:             }

 523:             set {

 524:                 if ((value != this._priority)) {

 525:                     this.OnPropertyChanging("Priority", this._priority);

 526:                     this._priority = value;

 527:                     this.OnPropertyChanged("Priority");

 528:                 }

 529:             }

 530:         }

 531:         

 532:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="TaskStatus", Storage="_taskStatus", FieldType="Choice")]

 533:         public virtual System.Nullable<TaskStatus> TaskStatus {

 534:             get {

 535:                 return this._taskStatus;

 536:             }

 537:             set {

 538:                 if ((value != this._taskStatus)) {

 539:                     this.OnPropertyChanging("TaskStatus", this._taskStatus);

 540:                     this._taskStatus = value;

 541:                     this.OnPropertyChanged("TaskStatus");

 542:                 }

 543:             }

 544:         }

 545:         

 546:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedToId", FieldType="User", IsLookupId=true)]

 547:         public System.Nullable<int> AssignedToId {

 548:             get {

 549:                 return this._assignedToId;

 550:             }

 551:             set {

 552:                 if ((value != this._assignedToId)) {

 553:                     this.OnPropertyChanging("AssignedToId", this._assignedToId);

 554:                     this._assignedToId = value;

 555:                     this.OnPropertyChanged("AssignedToId");

 556:                 }

 557:             }

 558:         }

 559:         

 560:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedTo", ReadOnly=true, FieldType="User", IsLookupValue=true)]

 561:         public string AssignedTo {

 562:             get {

 563:                 return this._assignedTo;

 564:             }

 565:             set {

 566:                 if ((value != this._assignedTo)) {

 567:                     this.OnPropertyChanging("AssignedTo", this._assignedTo);

 568:                     this._assignedTo = value;

 569:                     this.OnPropertyChanged("AssignedTo");

 570:                 }

 571:             }

 572:         }

 573:     }

 574:     

 575:     /// <summary>

 576:     /// Create a new list item.

 577:     /// </summary>

 578:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Item", Id="0x01", List="Empresas")]

 579:     internal partial class EmpresasItem : Item {

 580:         

 581:         private string _sede;

 582:         

 583:         private System.Nullable<double> _plantilla;

 584:         

 585:         #region Extensibility Method Definitions

 586:         partial void OnLoaded();

 587:         partial void OnValidate();

 588:         partial void OnCreated();

 589:         #endregion

 590:         

 591:         public EmpresasItem() {

 592:             this.OnCreated();

 593:         }

 594:         

 595:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Sede", Storage="_sede", FieldType="Text")]

 596:         public string Sede {

 597:             get {

 598:                 return this._sede;

 599:             }

 600:             set {

 601:                 if ((value != this._sede)) {

 602:                     this.OnPropertyChanging("Sede", this._sede);

 603:                     this._sede = value;

 604:                     this.OnPropertyChanged("Sede");

 605:                 }

 606:             }

 607:         }

 608:         

 609:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Plantilla", Storage="_plantilla", FieldType="Number")]

 610:         public System.Nullable<double> Plantilla {

 611:             get {

 612:                 return this._plantilla;

 613:             }

 614:             set {

 615:                 if ((value != this._plantilla)) {

 616:                     this.OnPropertyChanging("Plantilla", this._plantilla);

 617:                     this._plantilla = value;

 618:                     this.OnPropertyChanged("Plantilla");

 619:                 }

 620:             }

 621:         }

 622:     }

 623:     

 624:     /// <summary>

 625:     /// Track a work item that you or your team needs to complete.

 626:     /// </summary>

 627:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Task", Id="0x0108", List="Tareas")]

 628:     internal partial class TareasTask : Task {

 629:         

 630:         private Microsoft.SharePoint.Linq.EntitySet<Item> _predecessors;

 631:         

 632:         #region Extensibility Method Definitions

 633:         partial void OnLoaded();

 634:         partial void OnValidate();

 635:         partial void OnCreated();

 636:         #endregion

 637:         

 638:         public TareasTask() {

 639:             this._predecessors = new Microsoft.SharePoint.Linq.EntitySet<Item>();

 640:             this._predecessors.OnSync += new System.EventHandler<Microsoft.SharePoint.Linq.AssociationChangedEventArgs<Item>>(this.OnPredecessorsSync);

 641:             this._predecessors.OnChanged += new System.EventHandler(this.OnPredecessorsChanged);

 642:             this._predecessors.OnChanging += new System.EventHandler(this.OnPredecessorsChanging);

 643:             this.OnCreated();

 644:         }

 645:         

 646:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="DueDate", Storage="_dueDate", FieldType="DateTime")]

 647:         public override System.Nullable<System.DateTime> DueDate {

 648:             get {

 649:                 return this._dueDate;

 650:             }

 651:             set {

 652:                 if ((value != this._dueDate)) {

 653:                     this.OnPropertyChanging("DueDate", this._dueDate);

 654:                     this._dueDate = value;

 655:                     this.OnPropertyChanged("DueDate");

 656:                 }

 657:             }

 658:         }

 659:         

 660:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Status", Storage="_taskStatus", FieldType="Choice")]

 661:         public override System.Nullable<TaskStatus> TaskStatus {

 662:             get {

 663:                 return this._taskStatus;

 664:             }

 665:             set {

 666:                 if ((value != this._taskStatus)) {

 667:                     this.OnPropertyChanging("TaskStatus", this._taskStatus);

 668:                     this._taskStatus = value;

 669:                     this.OnPropertyChanged("TaskStatus");

 670:                 }

 671:             }

 672:         }

 673:         

 674:         [Microsoft.SharePoint.Linq.AssociationAttribute(Name="Predecessors", Storage="_predecessors", MultivalueType=Microsoft.SharePoint.Linq.AssociationType.Multi, List="Tareas")]

 675:         public Microsoft.SharePoint.Linq.EntitySet<Item> Predecessors {

 676:             get {

 677:                 return this._predecessors;

 678:             }

 679:             set {

 680:                 this._predecessors.Assign(value);

 681:             }

 682:         }

 683:         

 684:         private void OnPredecessorsChanging(object sender, System.EventArgs e) {

 685:             this.OnPropertyChanging("Predecessors", this._predecessors.Clone());

 686:         }

 687:         

 688:         private void OnPredecessorsChanged(object sender, System.EventArgs e) {

 689:             this.OnPropertyChanged("Predecessors");

 690:         }

 691:         

 692:         private void OnPredecessorsSync(object sender, Microsoft.SharePoint.Linq.AssociationChangedEventArgs<Item> e) {

 693:         }

 694:     }

 695:     

 696:     /// <summary>

 697:     /// Group and describe related tasks that you or your team needs to complete.

 698:     /// </summary>

 699:     [Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Summary Task", Id="0x012004", List="Tareas")]

 700:     internal partial class TareasSummaryTask : SummaryTask {

 701:         

 702:         private Microsoft.SharePoint.Linq.EntitySet<Item> _predecessors;

 703:         

 704:         #region Extensibility Method Definitions

 705:         partial void OnLoaded();

 706:         partial void OnValidate();

 707:         partial void OnCreated();

 708:         #endregion

 709:         

 710:         public TareasSummaryTask() {

 711:             this._predecessors = new Microsoft.SharePoint.Linq.EntitySet<Item>();

 712:             this._predecessors.OnSync += new System.EventHandler<Microsoft.SharePoint.Linq.AssociationChangedEventArgs<Item>>(this.OnPredecessorsSync);

 713:             this._predecessors.OnChanged += new System.EventHandler(this.OnPredecessorsChanged);

 714:             this._predecessors.OnChanging += new System.EventHandler(this.OnPredecessorsChanging);

 715:             this.OnCreated();

 716:         }

 717:         

 718:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="DueDate", Storage="_dueDate", FieldType="DateTime")]

 719:         public override System.Nullable<System.DateTime> DueDate {

 720:             get {

 721:                 return this._dueDate;

 722:             }

 723:             set {

 724:                 if ((value != this._dueDate)) {

 725:                     this.OnPropertyChanging("DueDate", this._dueDate);

 726:                     this._dueDate = value;

 727:                     this.OnPropertyChanged("DueDate");

 728:                 }

 729:             }

 730:         }

 731:         

 732:         [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Status", Storage="_taskStatus", FieldType="Choice")]

 733:         public override System.Nullable<TaskStatus> TaskStatus {

 734:             get {

 735:                 return this._taskStatus;

 736:             }

 737:             set {

 738:                 if ((value != this._taskStatus)) {

 739:                     this.OnPropertyChanging("TaskStatus", this._taskStatus);

 740:                     this._taskStatus = value;

 741:                     this.OnPropertyChanged("TaskStatus");

 742:                 }

 743:             }

 744:         }

 745:         

 746:         [Microsoft.SharePoint.Linq.AssociationAttribute(Name="Predecessors", Storage="_predecessors", MultivalueType=Microsoft.SharePoint.Linq.AssociationType.Multi, List="Tareas")]

 747:         public Microsoft.SharePoint.Linq.EntitySet<Item> Predecessors {

 748:             get {

 749:                 return this._predecessors;

 750:             }

 751:             set {

 752:                 this._predecessors.Assign(value);

 753:             }

 754:         }

 755:         

 756:         private void OnPredecessorsChanging(object sender, System.EventArgs e) {

 757:             this.OnPropertyChanging("Predecessors", this._predecessors.Clone());

 758:         }

 759:         

 760:         private void OnPredecessorsChanged(object sender, System.EventArgs e) {

 761:             this.OnPropertyChanged("Predecessors");

 762:         }

 763:         

 764:         private void OnPredecessorsSync(object sender, Microsoft.SharePoint.Linq.AssociationChangedEventArgs<Item> e) {

 765:         }

 766:     }

 767:     

 768:     internal enum Priority : int {

 769:         

 770:         None = 0,

 771:         

 772:         Invalid = 1,

 773:         

 774:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="(1) Alta")]

 775:         _1Alta = 2,

 776:         

 777:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="(2) Normal")]

 778:         _2Normal = 4,

 779:         

 780:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="(3) Baja")]

 781:         _3Baja = 8,

 782:     }

 783:     

 784:     internal enum TaskStatus : int {

 785:         

 786:         None = 0,

 787:         

 788:         Invalid = 1,

 789:         

 790:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="No iniciada")]

 791:         NoIniciada = 2,

 792:         

 793:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="En curso")]

 794:         EnCurso = 4,

 795:         

 796:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="Completada")]

 797:         Completada = 8,

 798:         

 799:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="Aplazada")]

 800:         Aplazada = 16,

 801:         

 802:         [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="A la espera de otra persona")]

 803:         ALaEsperaDeOtraPersona = 32,

 804:     }

 805: }

Cómo vemos sólo contiene entidades relativas  a las listas Tareas y Empresas. Si representamos el correspondiente diagrama de clases, este hecho quedará mucho más claro.

image

Publicado por

Juan Carlos González

Juan Carlos es Ingeniero de Telecomunicaciones por la Universidad de Valladolid y Diplomado en Ciencias Empresariales por la Universidad Oberta de Catalunya (UOC). Cuenta con más de 12 años de experiencia en tecnologías y plataformas de Microsoft diversas (SQL Server, Visual Studio, .NET Framework, etc.), aunque su trabajo diario gira en torno a SharePoint & Office 365. Juan Carlos es MVP de Office Servers & Services desde 2015 (anteriormente fue reconocido por Microsoft como MVP de Office 365 y MVP de SharePoint Server desde 2008 hasta 2015), coordinador del grupo de usuarios .NET de Cantabria (Nuberos.Net, www.nuberos.es), co-fundador y coordinador del Grupo de Usuarios de SharePoint de España (SUGES, www.suges.es), así como co-director de la revista gratuita en castellano sobre SharePoint CompartiMOSS (www.compartimoss.com). Hasta la fecha, ha publicado 8 libros sobre SharePoint & Office 365 y varios artículos en castellano y en inglés sobre ambas plataformas.

3 comentarios en “SharePoint 2010: Como generar un proxy LINQ To SharePoint con ciertas listas y tipos de contenido!”

  1. Hola!, buen posts!, como todos los del site.
    Una pregunta, se puede cambiar el atributo ListAttribute(Name=”Empresas”) en runtime para que el nombre de la lista sea configurable?.

  2. Hola Fernando,
    No veo porque no, eso sí ten en cuenta que SPMetal genera un modelo “estático” y tú quieres ir más allá…tendrías que generar tu propio modelo dinámico partiendo de la base de lo que te genera spmetal.

    Saludos

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *