Thank you MSDN Team Blog: Using LINQ-to-SharePoint with Choice Fields<http://blogs.msdn.com/b/sharepointdev/archive/2011/05/03/using-linq-to-sharepoint-with-choice-fields.aspx>
I can breathe again. :) From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Paul Noone Sent: Wednesday, 15 February 2012 2:41 PM To: 'ozMOSS' Subject: RE: SPMetal and LINQ code generation I regenerated the Linq code again and this time there is no error. The code generated for the choice field is not enum but class. public sealed class EventCategory { public const string General = "General"; public const string TermDates = "Term Dates"; public const string SocialEvents = "Social Events"; } And it is now using public virtual string. Go figure. :) In any case, this highlights a pretty big problem. This field allows fill-in choices. What happens when the user adds a new value?!? Is there any way to make the definition less static? From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Paul Noone Sent: Wednesday, 15 February 2012 2:18 PM To: 'ozMOSS' Subject: RE: SPMetal and LINQ code generation Thanks for the tip Prashanth. I can't see anything obvious so have just removed it from the code. Hope that doesn't cause more problems later. :) From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Prashanth Thiyagalingam Sent: Wednesday, 15 February 2012 2:10 PM To: ozmoss@ozmoss.com Subject: RE: SPMetal and LINQ code generation Hi Paul, Choice fields are normally a problem with SPMetal LINQ because SPMetal create an enum for the values in the choice field and they are bound to the field it self. Make sure you have values for Choice field and regenerate the SPMetal class. To double check all the values are retreived properlly, do a search for 'enum EventCategory' in the LINQ class created by SPMetal Cheers, Prashanth ________________________________ From: paul.no...@ceosyd.catholic.edu.au To: ozmoss@ozmoss.com Date: Wed, 15 Feb 2012 13:28:59 +1100 Subject: SPMetal and LINQ code generation Hi all, I'm using spmetal to generate the Linq source for a visual web part project. Unfortunately the returned code for a Choice field in a custom content types is throwing errors. 1817 The type 'ReceiversAndWPs.LinqVWP.EventCategory' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable<T>' 1817 'ReceiversAndWPs.LinqVWP.EventsCEOEvent.EventCategory': type must be 'string' to match overridden member 'ReceiversAndWPs.LinqVWP.CEOEvent.EventCategory' 1816 [Microsoft.SharePoint.Linq.ColumnAttribute(Name="Event_x0020_Category", Storage="_eventCategory", Required=true, FieldType="Choice")] 1817 public override System.Nullable<EventCategory> EventCategory { 1818 get { 1819 return this._eventCategory; 1820 } 1821 set { 1822 if ((value != this._eventCategory)) { 1823 this.OnPropertyChanging("EventCategory", this._eventCategory); 1824 this._eventCategory = value; 1825 this.OnPropertyChanged("EventCategory"); 1826 } 1827 } 1828 } All other choice fields were defined in the same manner but only this one is throwing an error. Converting this to a string resolves the problem but is it the right thing to do?? 1817 public override string EventCategory { Kind regards, Paul Noone --------------------------------------------------- Online Developer/SharePoint Administrator Infrastructure Team, ICT Catholic Education Office, Sydney p: (02) 9568 8461 f: (02) 9568 8483 e: paul.no...@ceosyd.catholic.edu.au<mailto:paul.no...@ceosyd.catholic.edu.au> w: http://www.ceosyd.catholic.edu.au/ _______________________________________________ ozmoss mailing list ozmoss@ozmoss.com<mailto:ozmoss@ozmoss.com> http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
_______________________________________________ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss