Field Naming Rules Issue

4 posts, 1 answers
  1. bradhh
    bradhh avatar
    25 posts
    Member since:
    Feb 2007

    Posted 05 Dec 2012 Link to this post

    First off, I am new at using OpenAccess, so hopefully this will be a simple issue that I just haven't figured out yet.

    When building my project I am getting the error, "There is not field with the name 'id' backing 'Id' property in the type 'Address'..."

    My address object includes a backing object that is not exposed publicly, but the fields are mapped to allow access without exposing implementation. Here is an example:

    public class BaseItem
    {
      public int Id { get; set; }
      //  ... other logic ...
    }
     
     
    public class Address
    {
      private BaseItem BaseItem { get; set; };
      public int Id
      {
        get
        {
          return this.BaseItem.Id;
        }
        set
        {
          this.BaseItem.Id = value;
        }
      }
    }
     
     
    public class SampleMetaData : FluentMetadataSource
    {
      protected override IList<MappingConfiguration> PrepareMapping()
      {
        List<MappingConfiguration> configurations = new List<MappingConfiguration> ();
     
        MappingConfiguration<Address> addressConfig = new MappingConfiguration<Address> ();
        addressConfig.MapType ( x => new
        {
          Id = x.Id
        } ).ToTable ( "Addresses" );
        addressConfig.HasProperty ( x => x.Id ).IsIdentity ( KeyGenerator.Autoinc );
     
        configurations.Add ( addressConfig );
     
        return configurations;
      }
    }

    I have tried using the .HasFieldName() method in a variety of ways, but I cannot get it to map the Id field.

    Why does the MappingConfiguration care at all what my implementation is? Wouldn't it make sense to just use the publicly-exposed property rather than trying to access a private field that may or may not actually exist?

    Like I said, I'm very new to OpenAccess, so perhaps I am just missing something here.

    Thanks in advance for your help.

    Brad Harris
  2. Answer
    PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 10 Dec 2012 Link to this post

    Hi Brand,

     As I mentioned in the ticket you send earlier this is currently not supported feature. If this is an important feature for you we will definitely consider implementing it in the future (as we currently don't have such plans since that feature was never requested before).
    Would it make sense for you to open it as a pits item so that others people can view and give their opinion on the matter?

    All the best,
    Petar
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
  4. bradhh
    bradhh avatar
    25 posts
    Member since:
    Feb 2007

    Posted 10 Dec 2012 Link to this post

    I am not sure what a pits item is, but I would be happy to allow others to provide feedback.

    As I mentioned in the support ticket, this is a deal-breaker as far as using OpenAccess goes. Still, I am quite happy with the Telerik UI controls, and I am only just getting started with OA, so I haven't lost much time here. I will go back to my home-rolled data management for now.

    This doesn't seem like a terribly unusual design pattern: I pulled it straight out of the Gamma/Helm/Johnson/Vlissides Design Patterns text, the Composite pattern. It allows me to encapsulate my implementation in the base class, then expose just an interface. I am surprised that OpenAccess needs to know anything about the implementation of my classes, as that seems to violate the basic rule of Object Oriented Programming and Design Patterns.

    If you happen to provide an implementation of OA that works just on the exposed properties of the classes, please let me know. I am very happy with Telerik's products and the programming style overall, and would love to be able to use OA in future versions of my work.

    Thanks -

    Brad Harris
    brad@southcountysound.com
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 13 Dec 2012 Link to this post

    Hello Brad,

     The problem is that internally OpenAccess works with your fields and that can prove a little bit tricky in your case. We, however see your point and will definitely consider adding functionality like that.

    Kind regards,
    Petar
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top