XML序列化迁移到MySql [英] XML Serializiation migration to MySql

查看:48
本文介绍了XML序列化迁移到MySql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET项目,该项目使用XML序列化进行保存数据的主要操作.相对于数据大小,该项目应保持较小规模.但是,数据量一如既往地膨胀,现在我正在考虑使用基于SQL的替代方法来管理数据.

I have an ASP.NET project that uses XML Serialization for the main operation for saving data. This project was to stay small relative to size of data. However, the amount of data has ballooned as it always will and now I'm consider moving to a SQL based alternative for managing the data.

目前,我已经定义了多个对象,这些对象只是用于保存数据以使项目正常工作的存储类.

For now I have multiple objects defined that are simply storage classes for saving my data for the project to work.

public class Customer
{
     public Customer() { }
     public string Name { get; set; }
     public string PhoneNumber { get; set; }
}

public class Order
{
     public Order() { }
     public int ID { get; set; }
     public Date OrderDate { get; set; }
     public string Product { get; set; }
}

尽管不那么基本,但遵循这些思路.迁移到SQL似乎很容易,由于该服务的免费可用性,我一直使用MySql.我正在遇到的问题是,我现在看到的唯一方法是拥有一个解决方案,其中有一个存储类 Order 和一个用于加载/保存数据的类, OrderIO .

Something along these lines although not so rudimentary. Migrating to SQL seems to be a no-brainer and I've landed on using MySql because of the free availability of the service. What I'm running into is that the only way I can see to do this now is to have a solution where there is a storage class, Order, and a class built to Load/Save the data, OrderIO.

该项目在很大程度上依赖于使用List<>来填充页面上的数据字段.我没有使用任何内置的.NET控件(例如DataGrid)来帮助显示数据.填充在Page_Load上的简单TextBox或ComboBox控件.

The project relies heavily on using List<> to populate the data fields on the page. I'm not using any built-in .NET controls such as DataGrid to assist in displaying the data. Simple TextBox or ComboBox controls that are populated on Page_Load.

我知道最好选择一种方法,使数据字段可以通过Repeater绑定到SQL,但我没有考虑进行全面的重新设计,只是管理数据的基础架构有所不同

I'm aware it would make better sense to pick a way in which the data fields could bind to the SQL through a Repeater but I'm not looking at a full redesign, just a difference on the infrastructure to manage the data.

我希望能够创建一个类,该类可以从我正在执行的SQL语句中返回与我现在正在处理的对象类似的对象,例如List<>.我在开始使用最佳方法时遇到了一些麻烦.

I would like to be able to create a class that can return an object similar to what I'm dealing with now, such as List<>, from the SQL statements I'm executing. I'm having some trouble getting started on the best method of approach.

有关如何最好地使用SQL加载/保存数据的任何建议,或者有关使用.NET框架的一些思想的教程,都将有所帮助.这是一个笼统的问题,但我对大多数想法持开放态度.谢谢.

Any suggestions on how best to Load/Save this data using SQL or some tutorials on ideas using the .NET framework would be helpful. This is quite a generalized question but I'm open to most ideas. Thanks.

推荐答案

您需要的是一个数据访问层(DAL),它负责运行SQL代码并以所需的List<>格式返回所需的数据..我绝对建议您阅读Imar Spaanjar在

What you need is a Data Access Layer (DAL) that takes care of running the SQL code and returning the required data in the List<> format that you require. I would definitely recommend you read the two series of articles by Imar Spaanjar on Building a N-Layer Application. Note that there are two sets of series, but I linked to the second set, because it contains links to the first one.

此外,知道Sql Server 2008 R2 Express Edition是免费使用的,但每个数据库的限制为10 GB可能会有所帮助.我并不是说您不应该使用MySQL,而只是想通知您,以防您不知道有可用的Sql Server免费版本.

Also, it might be beneficial to know that Sql Server 2008 R2 express edition is free to use, but has a limit of 10 GB per database. I am not saying that you shouldn't use MySQL, but just wanted to inform you in case you didn't know that there is a free edition of Sql Server available.

这篇关于XML序列化迁移到MySql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆