我们如何从web.config映射数据库列 [英] how can we map database column from web.config

查看:53
本文介绍了我们如何从web.config映射数据库列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将使用来自不同网站的产品Feed。我必须将所有产品信息保存到数据库表中。

所有不同的站点都提供不同的源,如Excel或XML文件。我必须阅读Excel和XML文件并将数据保存到我们的数据库表中。

但是所有资源都有不同的列,我必须根据数据库表的列映射这些列。

我们可以映射web.config文件中的所有列。

如果是,请帮助我。 如何在asp.net 3.5的web.config文件中映射数据库表的列

推荐答案

这是我将如何做到的:



1.为每个提供者创建一个XML映射文件

2.为每个提供者编写一个Mapper类,它将解析相应的XML文件并返回映射的常见表示。

3.编写一个Factory类,它将基于提供者实例化正确的Mapper。

4.所有这些映射器都应该从一个抽象继承具有通用功能的基类。

5.编写一个将接收Mapper并从映射器中执行数据库工作的类。
Here's how I would do it:

1. Create an XML mapping file for each provider
2. Write a Mapper class for each provider that will parse the appropriate XML file and return a common representation of the mapping.
3. Write a Factory class that will instantiate the correct Mapper based on the provider.
4. All these mappers should inherit from an abstract base class that will have the common functionality.
5. Write a class that will take in a Mapper and do the database stuff from the mapper.


这篇关于我们如何从web.config映射数据库列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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