This is a migrated thread and some comments may be shown as answers.

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

1 Answer 149 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Warrick Hunter
Top achievements
Rank 1
Warrick Hunter asked on 14 Jun 2011, 02:19 PM
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.

1 Answer, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 17 Jun 2011, 07:27 AM
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.
Tags
Development (API, general questions)
Asked by
Warrick Hunter
Top achievements
Rank 1
Answers by
Serge
Telerik team
Share this question
or