Problem with Fluent Mapping API. Transient Properties not work working. Q1 2011

2 posts, 0 answers
  1. Warrick Hunter
    Warrick Hunter avatar
    1 posts
    Member since:
    Oct 2009

    Posted 14 Jun 2011 Link to this post

    Hi,

    I have just upgraded to Q1 2011 and now Transient properties are not working. I am using the per-class fluent mapping configuration. 

    Here is an example entity:
    public class Person
    {
        public static Telerik.OpenAccess.Metadata.Fluent.MappingConfiguration<Person> GetEntityMappingConfig()
        {
            MappingConfiguration<Person> config = new MappingConfiguration<Person>();
            config.MapType().ToTable("People");
            config.HasProperty(p => p.id).IsIdentity(KeyGenerator.Autoinc);
     
            config.HasProperty(p => p.IsAlive).AsTransient();
     
            return config;
        }
     
        public int id { get; set; }
        public string Name { get; set; }      
         
        public bool IsAlive
        {
            get
            {
                // Run some other function
                return true;
            }
            set
            {
                // do nothing
            }
        }
    }

    When the Context is created (or when the enhancer runs) it now throws this error:
    System.MissingFieldException: There is no field with name isAlive backing IsAlive property in type DAL.Person. 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.

    I can send a sample solution if needed.

    Thanks.
  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 17 Jun 2011 Link to this post

    Hello Warrick Hunter,

     Thanks a lot for noticing this, we have confirmed and fixed this issue and the fix will be available in the next release, most probably that is the Q2 release. For the time being though you can work around the issue by using the other MapType constructor. You code should look like: 

    public class Person
    {
        public static Telerik.OpenAccess.Metadata.Fluent.MappingConfiguration<Person> GetEntityMappingConfig()
        {
            MappingConfiguration<Person> config = new MappingConfiguration<Person>();
            config.MapType(x => new { x.id, x.Name }).ToTable("People");
     
            config.HasProperty(p => p.id).IsIdentity(KeyGenerator.Autoinc);
     
            return config;
        }
     
        public int id { get; set; }
        public string Name { get; set; }       
     
        public bool IsAlive
        {
            get
            {
                // Run some other function
                return true;
            }
            set
            
                // do nothing
            }
        }
    }

    I hope this helps. Again thanks for notifying us about this issue and please find your Telerik point updated.

    All the best,
    Serge
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  3. DevCraft banner
Back to Top