Skip to main content


Showing posts from December, 2012

Entity Framework Versus LINQ To SQL (comparison summary)

LINQ to SQL and ADO.NET Entity Framework are extensions of ADO.NET and are introduced to avoid difficulties involved in writing programs using object oriented programming languages to access data residing in RDBMS.
LINQ To SQL Entity Framework Complexity LINQ To SQL is easier to use. Entity Framework is more complex compared to LINQ To SQL. DB Server Support LINQ To SQL supports only Microsoft SQL Server. Entity Framework is built on top of ADO.NET data provider model and thus supports all existing ADO.NET data providers  i.e. IBM DB2, Sybase, Oracle, SQL Azure etc. File Type It uses Database Markup Language (DBML) file that contains XML mappings of entities to tables. Entity Framework uses four files EDMX, CSDL, SSDL and MSL. The later three are generated at runtime. Purpose Used for rapid application development. EF is used for enterprise n-tier application. Coupling LINQ To SQL is tightly coupled - object property to specific field of database or more correctly…

Export Sample series in C#, ASP.Net

In this export series I have written sample to export data in Excel, Text/CSV, PDF and HTML files.

You can check export sample here: Export to Excel – Export data in excel sheet. Export to Text/CSV – Export data in text/csv format. Export to PDF – Export application data in PDF file. Export to HTML – Export data in user defined HTML format. Export from Grid view to Excel.
Export Page Screen
I have used Visual Studio 2010 to write these samples, you can download source code of sample series here. Note: Source code doesn't include export from Grid view sample.

I hope you have enjoyed this series. Comment, feedback or any suggestion is always welcomed.


ASP.Net: Export to PDF and open with save file dialog.

In last sample of my exporting sample series, I will demonstrate how to export data to PDF file in C#, ASP.Net. To export data in PDF file I’ll use iTextsharp library, which is included in source code project. For this example I’ll use same “GetData” method (to get the data for exporting) which we had used in Export to Excel example, you can use your own method to get data, if any.
///<summary> /// Export to Pdf file. ///</summary> publicstaticvoid ExportPdfFile() { //Create MemoryStream Object. var stream = newMemoryStream();
//New Document with Page Size and Margins. var doc = newDocument(PageSize.LETTER, 50f, 50f, 40f, 40f);
// PdfWriter Object var writer = PdfWriter.GetInstance(doc, stream);     writer.SetFullCompression();
//Open document.     doc.Open();
//Font Factory to set font type, size and style. var style = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14f, Font.BOLD);
//Add header.     doc.Add(newParagraph("Export PDF Sample", style)         {    …

ASP.Net: Export to HTML file and save with save file dialog in C#.

So continuing from my exporting sample series here I am narrating how to export data to HTML file in C#, ASP.Net. For this example I’ll use same “GetData” method (to get the data for exporting) which we had used in Export to Excel example, you can use your own method to get data.