Bug in FluentMapping.ttinclude?

2 posts, 0 answers
  1. Phil
    Phil avatar
    2 posts
    Member since:
    Nov 2011

    Posted 16 Jan 2013 Link to this post

    Using the Fluent mapping type for the code generation, I have the following two classes in my model:
    public partial class UserDefinedColValue
    {
    public virtual string TABLE_NAME{get;set}
    public virtual string COL_NAME{get;set}
    public virtual string COL_VALUE{get;set}
    public virtual string AUDIT_OPERATOR{get;set;}
    public virtual DateTime AUDIT_DATE{get;set;}
            }

    and
    public partial class UserDefinedColumn
    {
    public virtual string TABLE_NAME {get;set}
    public virtual string COL_NAME {get;set;}
    public virtual string COL_DESC {get;set;}
    public virtual string AUDIT_OPERATOR {get;set;}
    public virtual DateTime AUDIT_DATE {get;set;}
    public virtual ObservableCollection<UserDefinedColValue> ColumnValues {get;}
    }

    This line is generated in the MetadataSource.cs
    public void PrepareUserDefinedColumnAssociationConfigurations(MappingConfiguration<UserDefinedColumn> configuration)
    {
    configuration.HasAssociation(x => x.ColumnValues)
                             .HasFieldName("_fLUSRDEFCOLVALUEs")
                             .HasConstraint((y, x) =>  x.TABLE_NAME == y.TABLE_NAME && x.COL_NAME == y.COL_NAME )
                             .WithDataAccessKind(DataAccessKind.ReadWrite);
    }

    This is the error:

    'System.Collections.ObjectModel.ObservableCollection<FundLinx.OA.UserDefinedColValue>' does not contain a definition for 'TABLE_NAME' and no extension method 'TABLE_NAME' accepting a first argument of type 'System.Collections.ObjectModel.ObservableCollection<FundLinx.OA.UserDefinedColValue>' could be found (are you missing a using directive or an assembly reference?)


  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 21 Jan 2013 Link to this post

    Hello Phil,

    The problem here is that you are trying to use ObservableCollection<T> as collection type for your list of UserDefinedColValue objects.

    In order to support change tracking in lists of persistent instances, OpenAccess needs one of its special collection types - TrackedList<T>, TrackedBindingList<T> or another that derives from any of them. By default collection fields are generated as List<T> but at runtime OpenAccess creates and uses instances of the aforementioned types.

    I am afraid that you will have to provide your own implementation of the INotifyCollectionChanged interface based on the TrackedList<T> type and use that in your persistent classes.

    All the best,
    Alexander
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  3. DevCraft banner
Back to Top