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

Using OA with ASP.Net dynamic data scaffolding!

7 Answers 218 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert Daggar
Top achievements
Rank 1
Robert Daggar asked on 16 Mar 2010, 09:58 PM
HI

We currently use Micrsoft's Dynamic Data scaffolding with the Telerik RadGrid and the Microsoft Entity Framework. However, we would prefer to replace the entity framework with Open Access.

This feature was inclued in the OA roadmap, with a delivery date of Feb 2010. However, I cannot find any reference to this in the new OA version.

Has this feature been included, and if so, where can I read about it?

7 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 17 Mar 2010, 04:50 PM
Hi Robert Daggar,

For the Q1 2010 release we were quite busy with the visual designer for OpenAccess and as much as we wanted to we did not have time to deliver the dynamic data support.
This feature is still on our TODO list and we will probably have an initial version soon.
If you are interested, we could notify you as soon as we have something that you can test?

Best wishes,
Jordan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Erkka
Top achievements
Rank 1
answered on 14 Oct 2010, 11:35 AM
Hi,

Any news on this feature? I wonder if it is still on track?

Best Regards,

Erkka
0
Jordan
Telerik team
answered on 18 Oct 2010, 03:08 PM
Hi Erkka,

Dynamic Data support is still on the road-map.
Unfortunately due to limited resources we have not been able to implement it in time for the Q3 2010 release.
We will probably increase the priority of this feature and implement it in time for the Q1 2011 release of OpenAccess.
In the mean time any feedback and suggestions that you may have are welcome.

Best wishes,
Jordan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Erkka
Top achievements
Rank 1
answered on 24 Nov 2010, 01:25 PM
Hi Jordan!

That is good news! When is the Q1/2011 due?

I have trying to get the OpenAccess to work with DynamicData by creating a
CustomDataModelProvider. Only associations are a bit more complicated 
and I have still not managed to get them work properly. 

OpenAccessDataSource needs also some work in order to get it to work with
QueryExtender. Just adding inheritance to IQueryableDatasource does not cut it.
It gets past the exception, but getting the filtering to actually work needs some more
tinkering. I would be interested to test any preliminary code you may have on this.

I'll also attach my code here in case someone else is interested in getting OpenAccess to work
with Dynamic data. Following code is not perfect in anyway and it is just something I've come up with
while testing to get OpenAccess to work with DynamicData.

public class CustomDataModelProvider : DataModelProvider
   {
 
       // Methods 
       public CustomDataModelProvider(object contextInstance, Func<object> contextFactory)
       {
           this.ContextFactory = contextFactory;
           MyFluentContext context = ((MyFluentContext)contextInstance) ?? ((MyFluentContext)this.CreateContext());
           this.ContextType = context.GetType();
           this.OATables = new List<TableProvider>();
 
           foreach (var entity in context.Metadata.PersistentTypes)
           {
               Telerik.OpenAccess.Metadata.IPersistentTypeDescriptor categoryDescriptor = context.Scope.PersistentMetaData.GetPersistentTypeDescriptor(entity.FullName);
               this.OATables.Add(new CustomTableProvider(this, entity, categoryDescriptor.DescribedType));
           }
           this.OATables.ForEach(delegate(TableProvider t)
           {
               ((CustomTableProvider)t).Initialize();
           });
       }
 
       public override object CreateContext()
       {
           return this.ContextFactory.Invoke();
       }
 
       //Properties
       internal List<TableProvider> OATables { get; set; }
       public override Type ContextType
       {
           get
           {
               return base.ContextType;
           }
           protected set
           {
               base.ContextType = value;
           }
       }
       private Func<object> ContextFactory { get; set; }
 
       public override System.Collections.ObjectModel.ReadOnlyCollection<TableProvider> Tables
       {
           get { return new ReadOnlyCollection<TableProvider>(this.OATables); ; }
       }
   }
 
   public class CustomTableProvider : TableProvider
   {
       private Type _entityType;
       //Methods
       public CustomTableProvider(CustomDataModelProvider dataModel, Telerik.OpenAccess.Metadata.MetaPersistentType entity, Type entityType)
           : base(dataModel)
       {
 
           this.Name = entity.Name;
           this.DataContextPropertyName = entity.Table.Name;
           this.EntityType = _entityType = entityType;
           this.OAColumns = new List<ColumnProvider>();
           foreach (var item in entity.Members)
           {
               CustomColumnProvider columnProvider = null;
               if (item.GetType() == typeof(Telerik.OpenAccess.Metadata.MetaPrimitiveMember))
                   columnProvider = new CustomColumnProvider(this, ((Telerik.OpenAccess.Metadata.MetaPrimitiveMember)item));
               if (item.GetType() == typeof(Telerik.OpenAccess.Metadata.MetaNavigationMember))
               {
                   columnProvider = new CustomColumnProvider(this, ((Telerik.OpenAccess.Metadata.MetaNavigationMember)item));
                
               }
               this.OAColumns.Add(columnProvider);
           }
       }
       public override IQueryable GetQuery(object context)
       {
           MethodInfo mi = typeof(MyFluentContext).GetMethod("GetAll");
           Type[] genericArguments = new Type[] { _entityType };
           MethodInfo genericMI = mi.MakeGenericMethod(genericArguments);
           return (IQueryable)genericMI.Invoke(context, new object[] { });           
       }
       internal void Initialize()
       {
           this.OAColumns.ForEach(delegate(ColumnProvider c)
           {
               ((CustomColumnProvider)c).Initialize();
           });
       }
       // Properties 
       internal List<ColumnProvider> OAColumns { get; set; }
 
       public override ReadOnlyCollection<ColumnProvider> Columns
       {
           get
           {
               return new ReadOnlyCollection<ColumnProvider>(OAColumns);
           }
       }
   }
 
   public class CustomColumnProvider : ColumnProvider
   {
       //Fields
       private AssociationProvider _association;
       private bool _isAssociation;
 
       //Methods
       public CustomColumnProvider(CustomTableProvider table, Telerik.OpenAccess.Metadata.MetaPrimitiveMember member)
           : base(table)
       {
           this.Member = member;
           this.ColumnType = ((Telerik.OpenAccess.Metadata.MetaPrimitiveType)member.MemberType).ClrType;
           this.IsGenerated = member.Column.IsBackendCalculated;
           this.IsPrimaryKey = member.Column.IsPrimaryKey;
           this._isAssociation = false;
           this.Nullable = member.Column.IsNullable.GetValueOrDefault(true);
           this.Name = member.PropertyName;
       }
       public CustomColumnProvider(CustomTableProvider table, Telerik.OpenAccess.Metadata.MetaNavigationMember member)
           : base(table)
       {
           this.Member = member;
           this.ColumnType = member.ClrType;
           this.IsPrimaryKey = false;
           this.IsForeignKeyComponent = true;
           this._isAssociation = true;
           this.Nullable = !(member.NullValueBehavior.Equals(Telerik.OpenAccess.Metadata.NullValueBehavior.Exception));
           this.Name = member.PropertyName;
       }
       internal void Initialize()
       {
           if (this._isAssociation && (this._association == null))
           {
               this._association = new CustomAssociationProvider(this);
           }
       }
       //Properties
       public Telerik.OpenAccess.Metadata.MetaMember Member { get; private set; }
 
       public override System.ComponentModel.AttributeCollection Attributes
       {
           get
           {
               List<Attribute> list = new List<Attribute>();
               list.Add(new ScaffoldColumnAttribute(true));
               return new System.ComponentModel.AttributeCollection(list.ToArray());
           }
       }
       public override AssociationProvider Association
       {
           get
           {
               this.Initialize();
               return this._association;
           }
       }
   }
   
   public class CustomAssociationProvider : AssociationProvider
   {
       //Methods
       //More or less not working...
       public CustomAssociationProvider(CustomColumnProvider column)
       {
           Telerik.OpenAccess.Metadata.MetaNavigationMember member = column.Member as Telerik.OpenAccess.Metadata.MetaNavigationMember;
           Telerik.OpenAccess.Metadata.MetaForeignKeyAssociation association = member.Association as Telerik.OpenAccess.Metadata.MetaForeignKeyAssociation;
           this.IsPrimaryKeyInThisTable = member.Master;
           this.FromColumn = column;
           var toTableName = association.AssociationEnds.First(p => p.PropertyName != column.Table.Name);
           this.ToTable = column.Table.DataModel.Tables.First(n => n.Name == toTableName.MemberType.Name);
           List<string> list = new List<string>();
           var toColumnName = toTableName.Association as Telerik.OpenAccess.Metadata.MetaForeignKeyAssociation;
           try
           {
               //if (toColumnName.Columns.First().TargetField != null)
               //    this.ToColumn = this.ToTable.Columns.First(c => c.Name == toColumnName.Columns.First().TargetField.Column.Name);
               //else
               this.ToColumn = this.ToTable.Columns.First(c => c.Name == toColumnName.Columns.First().Name);
               list.Add(ToColumn.Name);
 
           }
           catch { }
           this.ForeignKeyNames = new ReadOnlyCollection<string>(list);
           SetDirection(member);
       }
 
       internal void SetDirection(Telerik.OpenAccess.Metadata.MetaNavigationMember member)
       {
           if (member.Association.AssociationType == Telerik.OpenAccess.Metadata.AssociationType.OneToMany)
           {
               if (member.Multiplicity == Telerik.OpenAccess.Metadata.Multiplicity.Many)
                   this.Direction = AssociationDirection.OneToMany;
               else
                   this.Direction = AssociationDirection.ManyToOne;
           }
 
       }
 
   }
0
Jordan
Telerik team
answered on 26 Nov 2010, 11:38 AM
Hello Erkka,

Thank you for sharing your experience with the community.

The Q1 2011 release of OpenAccess is due in about 4 months.
If you would like to send us a simple project we could help you on resolving the issues with associations and then we could publish this as a code library project.

Greetings,
Jordan
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Erkka
Top achievements
Rank 1
answered on 28 Nov 2010, 09:29 PM
Hi Jordan,

I've submitted a sample project with ID 371031. 

It would be great to see this feature before Q1 2011.

Regards,

Erkka
0
Damyan Bogoev
Telerik team
answered on 29 Nov 2010, 06:47 PM
Hi Erkka,

Firstly I want to thank you for the provided application.
We will consider it as an option for our future Dynamic Data support. I sincerely hope that we will provide initial support for Dynamic Data before the next Q1 2011 release, maybe a service pack. Otherwise that is the release for which we target our support for Dynamic Data.

Best wishes,
Damyan Bogoev
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
General Discussions
Asked by
Robert Daggar
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Erkka
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or