1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Access/Modify Dynamic Data

Access/Modify Dynamic Data

9 posts, 0 answered
  1. martani
    martani avatar
    27 posts
    Registered:
    24 Jan 2011
    07 Apr 2011
    Link to this post
    Hi,

    I've created a Dynamic Type like this :

    App.WorkWith()
                    .DynamicData()
                    .Type()
                    .CreateNew("Lexique", "Telerik.Sitefinity.DynamicTypes.Model")
                    .Do(dt => dt.DatabaseInheritance = Telerik.Sitefinity.Metadata.Model.DatabaseInheritanceType.vertical)
     
                    .Field()
                        .TryCreateNew("acronym", typeof(string), ref changedDB)
                        .Done()
                    .Field()
                        .TryCreateNew("description", typeof(string), ref changedDB)
                        .Done()
     
                    .SaveChanges(true);

    Now I want to access/add new data to the database to the Lexique table.
    The tutorials in documentation show only when the document library is extended then accessed from the  
    App.WorkWith()
            .Documents()
            .Where(item => item.Parent.Title == "JobApplications" && item.Status == ContentLifecycleStatus.Live)

    But since I am using a separate type, I want to know how do I access elements from the type I've just created.

    Thank you.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    08 Apr 2011
    Link to this post
    Hello martani,

    Currently there is no a common facade or manager that will allow you to use your custom type directly and you have to use a custom manager and WCF RESTful service to update the data for your custom type. You can take a look at our Products sample that comes with SDK installation.

    There is a task in our TODO list about implementing common facade.

    Greetings,
    Ivan Dimitrov
    the Telerik team

  3. martani
    martani avatar
    27 posts
    Registered:
    24 Jan 2011
    08 Apr 2011
    Link to this post
    Thank you for your answer.

    Knowing that, I've tried to come up with something similar to the Intermedite Jobs module (My module would just be a dictionary of items with an acronym and description thus the Products Module sounds to be very complicated in my case).

    I followed exactly the instructions in the documentation along with making sure to not miss anything from the project from the SDK, my module builds successfully, but once on Sitefinity I get this erros message.

    The type Lexique.Data.OpenAccessLexiqueDataProvider is not interceptable.
    Parameter name: typeToIntercept

    This is the stack trace :
    [ArgumentException: The type Lexique.Data.OpenAccessLexiqueDataProvider is not interceptable.
    Parameter name: typeToIntercept]
       Telerik.Microsoft.Practices.Unity.InterceptionExtension.Interception.SetInterceptorFor(Type typeToIntercept, String name, ITypeInterceptor interceptor) +501
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, Type providerType, ExceptionPolicyName policy, ManagerBase`1 manager) +2211
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, ExceptionPolicyName policy, ManagerBase`1 manager) +74
       Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +214
       Lexique.LexiqueManager..ctor(String providerName) +50
       Lexique.LexiqueManager..ctor() +42
       Lexique.PublicControls.LexiqueItemsOverview.RadGrid1_NeedDataSource(Object source, GridNeedDataSourceEventArgs e) +87
       Telerik.Web.UI.RadGrid.OnNeedDataSource(GridNeedDataSourceEventArgs e) +191
       Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +109
       Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +254
       System.Web.UI.Control.LoadRecursive() +95
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +732
       System.Web.UI.Control.EnsureChildControls() +182
       System.Web.UI.Control.PreRenderRecursiveInternal() +73
       System.Web.UI.Control.PreRenderRecursiveInternal() +240
       System.Web.UI.Control.PreRenderRecursiveInternal() +240
       System.Web.UI.Control.PreRenderRecursiveInternal() +240
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3914

    There is no mention for the App.config file on the tutorial, and so far I can say that it is impossible for a beginner to develop a module so far. I've been trying for a month now, and adding dynamic fields to existing types doesn't seem promising for me, since I can have hundreds of items!

    I appreciate your help.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    08 Apr 2011
    Link to this post
    Hello martani,

    This looks like as an issue with the data model. I see that you use RadGrid to bind your data and this calls  OpenAccessLexiqueDataProvider . Can you send the data provider implementation?

    All the best,
    Ivan Dimitrov
    the Telerik team

  5. martani
    martani avatar
    27 posts
    Registered:
    24 Jan 2011
    08 Apr 2011
    Link to this post
    Thank you for your quick reply, this is my class OpenAccessLexiqueDataProvider

    01.[ContentProviderDecorator(typeof(OpenAccessContentDecorator))]
    02.    class OpenAccessLexiqueDataProvider: LexiqueDataProviderBase, IOpenAccessDataProvider
    03.    {
    04.        #region IOpenAccessDataProvider Members
    05.        public Database Database
    06.        {
    07.            get;
    08.            set;
    09.        }
    10. 
    11.        public TransactionMode TransactionConcurrency
    12.        {
    13.            get
    14.            {
    15.                return TransactionMode.OPTIMISTIC_NO_LOST_UPDATES;
    16.            }
    17.        }
    18. 
    19.        public bool UseImplicitTransactions
    20.        {
    21.            get
    22.            {
    23.                return true;
    24.            }
    25.        }
    26. 
    27.        public Assembly[] GetPersistentAssemblies()
    28.        {
    29.            return new[] { typeof(LexiqueItem).Assembly };
    30.        }
    31.        #endregion
    32. 
    33.        public override LexiqueItem CreateLexiqueItem()
    34.        {
    35.            return this.CreateLexiqueItem(new Guid());
    36.        }
    37. 
    38.        public override LexiqueItem CreateLexiqueItem(Guid guid)
    39.        {
    40.            var dateValue = DateTime.UtcNow;
    41. 
    42.            var item = new LexiqueItem()
    43.            {
    44.                Id = guid,
    45.                ApplicationName = this.ApplicationName,
    46.                Owner = SecurityManager.GetCurrentUserId(),
    47.                DateCreated = dateValue,
    48.                PublicationDate = dateValue
    49.            };
    50. 
    51.            ((IDataItem)item).Provider = this;
    52. 
    53.            if (guid != Guid.Empty)
    54.            {
    55.                this.GetScope().Add(item);
    56.            }
    57. 
    58.            return item;
    59.        }
    60. 
    61.        public override IQueryable<LexiqueItem> GetLexiqueItems()
    62.        {
    63.            var appName = this.ApplicationName;
    64. 
    65.            var query =
    66.                SitefinityQuery
    67.                .Get<LexiqueItem>(this, MethodBase.GetCurrentMethod())
    68.                .Where(b => b.ApplicationName == appName);
    69. 
    70.            return query;
    71.        }
    72. 
    73.        public override LexiqueItem GetLexiqueItem(Guid guid)
    74.        {
    75.            if (guid == Guid.Empty)
    76.                throw new ArgumentNullException("guid");
    77. 
    78.            var item = this.GetScope().GetItemById<LexiqueItem>(guid.ToString());
    79.            ((IDataItem)item).Provider = this;
    80.            return item;
    81.        }
    82. 
    83.        public override void DeleteLexiqueItem(LexiqueItem item)
    84.        {
    85.            var scope = this.GetScope();
    86.            if (scope != null)
    87.            {
    88.                scope.Remove(item);
    89.            }
    90.        }
    91.    }

    I am doing an exact imitation of the OpenAccessJobsDataProvider class in the Intermediate Jobs module.

    Thank you.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Apr 2011
    Link to this post
    Hello martani,

    The implementation looks fine, so the problem could be in the enhancer. If you want  you can open a support request and send the module implementation to us.

    All the best,
    Ivan Dimitrov
    the Telerik team

  7. dedi
    dedi avatar
    5 posts
    Registered:
    22 Oct 2008
    05 May 2011
    Link to this post
    Is there any way you could share your work/bring back the solution to these forums? I'm having the same issue with this code.
  8. martani
    martani avatar
    27 posts
    Registered:
    24 Jan 2011
    05 May 2011
    Link to this post
    I gave up, till some documentation shows up maybe
  9. Karen
    Karen avatar
    22 posts
    Registered:
    04 Aug 2010
    01 Jun 2011
    Link to this post
    I am having the same issue when trying to imitate  OpenAccessJobsDataProvider class, I was developing modules in 3.7 it was so easy, now it looks like a nightmare in 4.1, did anyone find any solution for this?
9 posts, 0 answered