I have some multi-level data described by a JSON string which I’m deserializing into a dynamic object using
Newtonsoft.Json.Linq.JObject.Parse(json)
I have some multi-level data described by a JSON string which I’m deserializing into a dynamic object using
Newtonsoft.Json.Linq.JObject.Parse(json)
Hi Tahir,
Another recent problem caused me to revisit this issue and renew my request that you add support for using dynamic/expando objects as data sources for BuildReport(). From other threads, it appears to be already logged as WORDSNET-12148, but I thought I would go ahead and ask again.
The benefit to me and other customers is that C# now makes it very easy to construct dynamic objects either by hand or using a JSON deserializer and it would be super-convenient to be able to pass these objects directly to BuildReport().
I have attached a small sample program that demonstrates what I would like to be able to do.
Thanks for your consideration,
Fred
aspose_dynamic_data_source.zip (146.7 KB)
Thanks for sharing the detail. We have logged this feature request as WORDSNET-16017 in our issue tracking system. You will be notified via this forum thread once this feature is available.
We apologize for your inconvenience.
Further to my last post, we suggest you please use DataSet/DataTable/DataRow objects when dealing with data having dynamic structure. The DataSet class has built-in capabilities to read data from a database or XML file/stream.
Please note that LINQ Reporting Engine enables to use the same syntax for DataSet/DataTable/DataRow objects (including extension methods) as would be used with regular class instances thus making report templates almost the same in both cases. Please refer to the following article for more information.
Working with Traditional Mail Merge Data Sources
Thanks for your patience.
Regarding support of dynamic data sources in LINQ Reporting, we have found a workaround involving recently introduced JsonDataSource and Newtonsoft Json.NET
. Please check the following code snippet. Hope this helps you.
// Initialize a dynamic object.
dynamic sender = new ExpandoObject();
sender.Message = "Hello";
// Serialize the dynamic object to JSON.
string json = JsonConvert.SerializeObject(sender);
// Initialize a JSON data source.
MemoryStream jsonStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
JsonDataSource dataSource = new JsonDataSource(jsonStream);
// Create a template document.
DocumentBuilder builder = new DocumentBuilder();
builder.Write("<<[Message]>>");
// Fill the template with data.
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(builder.Document, dataSource);
// Print the result document.
Console.WriteLine(builder.Document.GetText());