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

Bug in FluentMapping.ttinclude?

1 Answer 37 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Phil
Top achievements
Rank 1
Phil asked on 16 Jan 2013, 03:52 PM
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?)


1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 21 Jan 2013, 03:43 PM
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.
Tags
Data Access Free Edition
Asked by
Phil
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or