All previous topics were about Azure and how to work with that great technology. But each large project should be localized. We had a case when a project was under development for several years, had a big database and a lot of pages and needed to be localized.
In this article I will show you architecture for that localization. I will do it in simple way and will show general moments: how to save a current language? Work with localized database and localized strings in code or HTML.
First we need to open out MVC solution and database project.
Let's change our database project. In very first step we should create table “Language”:
In the previous article we have created Solution that has Web Role. It allows us to publish this solution on Windows Azure. Also, in this solution we have a connection to created storage account in Azure. We have log manager Log4net that allows us to write some logs in Blob table. In last article we have created a database in Windows Azure SQL server and a database project for this database. So now we can start to use this database in our solution. We will use Entity Framework for this purpose. Entity Framework allows generating entity classes from the database.
We will use EDMX file to do this. A .edmx file is an XML file that defines a conceptual model, a storage model, and the mapping between these models. An .edmx file also contains information that is used by the ADO.NET Entity Data Model Designer (Entity Designer) to render a model graphically. The recommended practice for creating an .edmx file is to use the Entity Data Model Wizard.
In the first step we should open our “MvcApplicationWebRole” solution. Now let’s add a new class library in our solution. Right click on the solution then “Add – New project”. In occurred window enter name “MvcApplicationWebRole.Database” and select “Class Library” as project type:
Add new project in solution
In this topic I will show you how to generate own database project from SQL Azure Database. We used SQL Management Studio 2012 to create and generate a database. Also, I will use our solution MvcApplicationWebRole that I have created and used in the previous post.
First you need to have created SQL Server in Azure. You can do it in Manage Windows Azure site.
New SQL server
To create new SQL server go by the link above and press button “+ New” in the bottom of the page. Then use the wizard and select action “Data Services – SQL database – Custom create”:
Wizard to create new Database on existing or new SQL Server
This post is related to the previous one - List instead of DataSet, with the ways how to convert DataTable to List.
However, it could be the case - when you need to do backfire - convert List to DataTable.
For example, it could be useful when you are working with Syncfusion and want to export your list to Excel document. This Syncfusion framework does the method that will export a list to Excel. We just have:
But there are no methods that will get as input parameter some List and return to Excel in the result.
So we have created an extension method for List that allows us to convert List to DataTable. It is very useful. You can work in your solution with List. And just in the end when you want to export that List to Excel - you can call the method that will convert your List to DataTable. The code is very simple: