Access/Modify Dynamic Data
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);
App.WorkWith()
.Documents()
.Where(item => item.Parent.Title == "JobApplications" && item.Status == ContentLifecycleStatus.Live)
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
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
[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
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
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.
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
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.
I gave up, till some documentation shows up maybe
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?