I have added sync fusion package to my android project using nuget installer with the below command.
install-package Syncfusion.Xamarin.XlsIO -sourcehttp://nuget.syncfusion.com/xamarin
The worksheet interface contains reference only to import data, the methods to import data table are not found. Should the sync fusion package be added in any other way? Please help on this
XlsIO provides portable class library for Xamarin platform. As the data table is not supported in portable platform, so XlsIO doesn’t support import data table into worksheet. However, you can convert the data table into an enumerable object and then import that object into worksheet using Worksheet.ImportData() method.
To know more about import data into worksheet, kindly refer the following documentation.
Documentation: https://help.syncfusion.com/file-formats/xlsio/working-with-data#import-data-from-business-objects
However this requirement can be achieved by an workaround. The sample can be downloaded from the following link
Sample link : http://www.syncfusion.com/downloads/support/directtrac/general/ze/XamarineSample1612899830.zip
Kindly refer the following code snippet for your reference
Code Snippet:
private IEnumerable<dynamic> GetDynamicData(DataTable table)
{
List<dynamic> dynamicData = new List<dynamic>(table.Rows.Count);
foreach (DataRow row in table.Rows)
{
ExpandoObject expando = new ExpandoObject();
foreach (DataColumn column in table.Columns)
{
(expando as IDictionary<string, object>).Add(column.ColumnName, row[column]);
}
dynamicData.Add(expando);
}
return dynamicData;
}
I work for Syncfusion.
Regards,
Abirami
Related
Sorry for this question as I'm new to asp.net. I need to make Import Csv files into database that is made in sql server and added to web application by entity framework. I managed to export it, but have no clue how to import it other than maybe using StreamReader with regex. Tried using Lumenworks csvreader, but it doesn't cooparate with entity.
You can look at the CsvHelper NuGet package. You can find parts of the code you need to use here.
Relevant code:
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
CsvReader csvReader = new CsvReader(reader);
csvReader.Configuration.WillThrowOnMissingField = false;
var countries = csvReader.GetRecords<Country>().ToArray();
context.Countries.AddOrUpdate(c => c.Code, countries);
}
I'm aware that there are some commercial libraries and that there's AddRange, but AFAIK AddRange does piecemeal INSERTs under the hood.
I'm looking for a free utility that I can use to add a collection of new entities all at the same time - does one exist for EF6?
I would suggest you take a look at N.EntityFramework.Extension. It is a basic bulk extension framework for EF 6 that is available on Nuget and the source code is available on Github under MIT license.
Install-Package N.EntityFramework.Extensions
https://www.nuget.org/packages/N.EntityFramework.Extensions
Once you install it you can simply use BulkInsert() method directly on the DbContext instance. It support BulkDelete, BulkInsert, BulkMerge and more.
BulkDelete()
var dbcontext = new MyDbContext();
var orders = dbcontext.Orders.Where(o => o.TotalPrice < 5.35M);
dbcontext.BulkDelete(orders);
BulkInsert()
var dbcontext = new MyDbContext();
var orders = new List<Order>();
for(int i=0; i<10000; i++)
{
orders.Add(new Order { OrderDate = DateTime.UtcNow, TotalPrice = 2.99 });
}
dbcontext.BulkInsert(orders);
You can use the following library:
https://github.com/MikaelEliasson/EntityFramework.Utilities
It works well for simple bulk inserts and updates.
You should also look at the following post if you want to find out about other options to achieve bulk insert:
Fastest Way of Inserting in Entity Framework
I try to implement an API using the RPC dart package.
In all the example I found, response are build manually (ie new Response()..message = "hello").
In my case, i read JSON data from mongodb and want to return them with minimal transformation (basically picking only external properties).
The fromRequest of the method schema can be used to do this :
class QueryResult {
//my props
}
#ApiMethod(path: "myMongoQuery")
Future<List<QueryResult>> myMongoQuery() async {
var schema = _server.apiMap["/query/v1"].schemaMap["QueryResult"];
var results = await coll.find();
return results.map(schema.fromRequest).toList();
}
The problem in my code is the first line (_server.apiMap["/query/v1"].schemaMap["QueryResult"]) it's a pure hack to retrieve the schema of my method.
I tried to use mirror to retrieve the schema in an elegant/generic way but did not succeed.
Anyone can help me on this ?
Cheers,
Nicolas
As a followup question to the following question and answer:
https://stackoverflow.com/questions/31156774/about-key-grouping-with-groupbykey
I'd like to confirm with google dataflow engineering team (#jkff) if the 3rd option proposed by Eugene is at all possible with google dataflow:
"have a ParDo that takes these keys and creates the BigQuery tables, and another ParDo that takes the data and streams writes to the tables"
My understanding is that ParDo/DoFn will process each element, how could we specify a table name (function of the keys passed in from side inputs) when writing out from processElement of a ParDo/DoFn?
Thanks.
Updated with a DoFn, which is not working obviously since c.element().value is not a pcollection.
PCollection<KV<String, Iterable<String>>> output = ...;
public class DynamicOutput2Fn extends DoFn<KV<String, Iterable<String>>, Integer> {
private final PCollectionView<List<String>> keysAsSideinputs;
public DynamicOutput2Fn(PCollectionView<List<String>> keysAsSideinputs) {
this.keysAsSideinputs = keysAsSideinputs;
}
#Override
public void processElement(ProcessContext c) {
List<String> keys = c.sideInput(keysAsSideinputs);
String key = c.element().getKey();
//the below is not working!!! How could we write the value out to a sink, be it gcs file or bq table???
c.element().getValue().apply(Pardo.of(new FormatLineFn()))
.apply(TextIO.Write.to(key));
c.output(1);
}
}
The BigQueryIO.Write transform does not support this. The closest thing you can do is to use per-window tables, and encode whatever information you need to select the table in the window objects by using a custom WindowFn.
If you don't want to do that, you can make BigQuery API calls directly from your DoFn. With this, you can set the table name to anything you want, as computed by your code. This could be looked up from a side input, or computed directly from the element the DoFn is currently processing. To avoid making too many small calls to BigQuery, you can batch up the requests using finishBundle();
You can see how the Dataflow runner does the streaming import here:
https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/sdk/src/main/java/com/google/cloud/dataflow/sdk/util/BigQueryTableInserter.java
I created a bare-bones datagrid using web-ui for testing and had it working just fine. Then I decided to try to declare it as a component. I changed around the library references and now it is giving me the above error when I try to run the application. You can see my file structure below. The reason I am getting the "ambiguous reference" message when I try to run it is that when I went into the auto-generated DataGrid.dart file in the out directory, it had the following declaration
import 'DataGrid.dart';
...
import '../DataGrid.dart';
I am confused as to why the generated code imports them both. One thing that I considered is that it could be because the DataGridPage.html file instantiates my DataGrid component and my DataGridPage.dart file imports DataGrid.dart so that it can have references to DataGridColumn (it needs to set the columns for the DataGrid). In DataGridPage.dart, I also attach to certain DataGrid events such as SortColumnChanged and SelectionChanged so I need to request a copy of my DataGrid instance in DataGridPage.dart (I don't think there is a way to attach to events from the web component instantiation in DataGridPage.html).
Any ideas about what I am doing wrong?
Here is my file structure:
DataGrid.dart
--------------------------------------------
library datagrid;
...
part 'DataGridColumn.dart';
part 'DataGridRow.dart';
class DataGrid extends WebComponent{...}
DataGridRow.dart
--------------------------------------------
part of datagrid;
class DataGridRow {...}
DataGridColumn.dart
--------------------------------------------
part of datagrid;
class DataGridColumn {...}
DataGrid.html
--------------------------------------------
[contains the component declaration UI]
DataGridPage.html
-----------------------------------------
...
<div is="s-datagrid" id="myDataGrid" ItemsSource="{{app.Assets}}" Columns="{{app.Columns}}"></div>
...
DataGridPage.dart
--------------------------------------------
import 'DataGrid.dart';
import 'Asset.dart';
void main() {
}
DataGridApp _app;
DataGridApp get app {
if (_app == null) {
_app = new DataGridApp();
}
return _app;
}
class DataGridApp{
//provides ItemsSource and DataGridColumn data
}
jmesserly has answered this on the github site. He said that you need to remove the component import in your main dart file. So in my example I would remove the import 'DataGrid.dart' statement from the DataGridPage.dart. The IDE will give you a warning but you can ignore it because it will actually be run from the out folder.
GitHub Web-UI Issue 342