Error when using underscores in attribute names in a custom

Posted by Community Admin on 04-Aug-2018 16:18

Error when using underscores in attribute names in a custom module

All Replies

Posted by Community Admin on 15-May-2012 00:00

Hello,
I'm running an instance of Sitefinity 5.0.2500, and I'm working with developing custom modules. I was attempting to add an attribute to my Model.Item class (that is, my data item class) that contained an underscore in it. For example:

private string first_Name;
 
[DataMember]
public string FirstName get return first_Name; set first_Name = value;

As you can see, I have an attribute with the name "first_Name". With this present, any time I attempt to build by project (which contains my module) results in a build error that states the following:
Error   78  There is no field with name 'firstName' backing 'FirstName' property in type 'PrimaryFMAs.Model.PrimaryFMAItem'. You need to either change the Field Naming rules of the mapping configuration object or call HasFieldName(string) with the name of the backing field.
ExceptionString:
System.MissingFieldException: There is no field with name 'firstName' backing 'FirstName' property in type 'PrimaryFMAs.Model.PrimaryFMAItem'. You need to either change the Field Naming rules of the mapping configuration object or call HasFieldName(string) with the name of the backing field.
   at Telerik.OpenAccess.Metadata.Fluent.PropertyInfoHelper.GetFieldInfo(String fieldName, String propertyName, Type type)
   at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.GetMemberType()
   at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.AddConceptualItem(FluentMetadataSource fluentMappingSource, MetaPersistentType persistentType)
   at Telerik.OpenAccess.Metadata.Fluent.MappingConfiguration.AddEntityMapping(MetadataContainer metadataContainer, MetaTable table)
   at Telerik.OpenAccess.Metadata.Fluent.MappingConfiguration.AddEntityMapping(MetadataContainer metadataContainer)
   at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.CreateModel()
   at Telerik.Sitefinity.Data.OA.SitefinityMetadataSourceBase.CreateModel()
   at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.GetModelCore(MetadataContainer model)
   at Telerik.OpenAccess.Sdk.Enhancer.Enhancer.CrossDomainRunImpl(AssemblyLoader assemblyLoader)
   at Telerik.OpenAccess.Sdk.Enhancer.EnhancerBase.CrossDomainRun() C:\inetpub\wwwroot\_Shootmeintheface_a\PrimaryFMA\obj\Debug\PrimaryFMACatalogSample.dll PrimaryFMACatalogSample

Obviously, I was able to get around this by removing the underscores from my attributes, but, I just wanted to post this here in case someone else came accross this issue and didn't understand why.

This thread is closed