Wednesday, July 9, 2014
Monday, July 5, 2010
C# 4.0 Dynamic and Expando
The most exciting C# 4.0 feature for me is the dynamic.
It significantly lowered the cost to create more fluent and beautiful API.
Below is the slide from my lightning talk at Sydney ALT.NET June meeting.
http://www.slideshare.net/wiryadi/c-40-dynamic
The source code for CoolSQL will be available on GitHub
http://github.com/wiryadi/DynamicSQL
It significantly lowered the cost to create more fluent and beautiful API.
Below is the slide from my lightning talk at Sydney ALT.NET June meeting.
http://www.slideshare.net/wiryadi/c-40-dynamic
The source code for CoolSQL will be available on GitHub
http://github.com/wiryadi/DynamicSQL
Thursday, October 23, 2008
Fluent Spring is Alive
Fluent Spring project is alive. It is hosted at google code.
It is still very rough.
The project delivers DSL to configure Spring.NET in C#, no XML required.
Check it out at http://code.google.com/p/fluent-spring
It is still very rough.
The project delivers DSL to configure Spring.NET in C#, no XML required.
Check it out at http://code.google.com/p/fluent-spring
Wednesday, October 15, 2008
Spring.NET fluent configuration
Mission
I like Spring.NET framework. But I am not a fan of xml configuration.
Spring.NET has programmatic configuration API. Refer to Mark Pollack's blog
However, the api is awkward to work with.
Plan
I like the wayAutofac's fluent configuration.I plan to create a helper class to provide fluent configuration for Spring.NET a'la Autofac.
Sunday, August 5, 2007
Benchmarking SqlBulkCopy
Bulk uploading into SQL Server programmatically has always been slow and tedious exercise.
Fortunately Microsoft has included SqlBulkCopy in the SqlClient for ADO.NET 2.0
In my testing. I loaded Australia's PostCode list from csv file, consisting of 16,789 rows.
I compared SqlAdapter.Fill(), SqlAdapterFill() + Setting the UpdateBatchSize property, and finally I used SqlBulkCopy.
First I read the csv file into in memory DataTable. For this purpose I read all rows in one go. In real live application, we would need to page the operation.
Then I push the DataTable into SqlServer 2005 table using 3 different methods.
Option 2 took 9,636 ms
and .....
Option 3 took 568 ms
Wow,.....
I suspect that option 1 and option 2 difference would be more significant if the SQL Server is located accross network. In this test I use local SQL Server.
To do SqlBulkCopy is surprisingly simple:
You need only to specify the connection string, the datatable and the name of the destination table.
string connectionString = "....";
DataTable csvTable = PopulateTable();
SqlBulkCopy bcp = new SqlBulkCopy(connectionString );
bcp.DestinationTableName = "PostCodes";
bcp.WriteToServer(csvTable);
Here are snippet of the code from my Benchmark Harness, which is a winforms application
Fortunately Microsoft has included SqlBulkCopy in the SqlClient for ADO.NET 2.0
In my testing. I loaded Australia's PostCode list from csv file, consisting of 16,789 rows.
I compared SqlAdapter.Fill(), SqlAdapterFill() + Setting the UpdateBatchSize property, and finally I used SqlBulkCopy.
First I read the csv file into in memory DataTable. For this purpose I read all rows in one go. In real live application, we would need to page the operation.
Then I push the DataTable into SqlServer 2005 table using 3 different methods.
- SqlAdapter.Fill
- SqlAdapter.Fill + Setting the UpdateBatchSize property = 500
- SqlBulkCopy
Option 2 took 9,636 ms
and .....
Option 3 took 568 ms
Wow,.....
I suspect that option 1 and option 2 difference would be more significant if the SQL Server is located accross network. In this test I use local SQL Server.
To do SqlBulkCopy is surprisingly simple:
You need only to specify the connection string, the datatable and the name of the destination table.
string connectionString = "....";
DataTable csvTable = PopulateTable();
SqlBulkCopy bcp = new SqlBulkCopy(connectionString );
bcp.DestinationTableName = "PostCodes";
bcp.WriteToServer(csvTable);
Here are snippet of the code from my Benchmark Harness, which is a winforms application
Subscribe to:
Posts (Atom)