I have a strange situation. I have created a data model visually and generated a database from it. This project is referenced by two projects:
我有一个奇怪的情况。我已经可视地创建了一个数据模型并从中生成了一个数据库。该项目由两个项目引用:
- ASP .NET application.
- WinForms application.
ASP .NET应用程序。
The ASP .NET application deals directly with the database while I need the WinForms application to interact with the database via the Web application.
ASP .NET应用程序直接处理数据库,而我需要WinForms应用程序通过Web应用程序与数据库交互。
I have created a page called API.aspx and use HTTP POST to send values and get results in XML.
我创建了一个名为API.aspx的页面,并使用HTTP POST发送值并以XML格式获取结果。
However, since the WinForms application still needs to use the data model classes, I am running into issues using them without creating a database object.
但是,由于WinForms应用程序仍然需要使用数据模型类,因此我遇到了使用它们的问题,而没有创建数据库对象。
What is a good strategy to use in this scenario?
在这种情况下使用什么是好策略?
2 个解决方案
#1
2
If you have implemented your code with loose coupling (See the Repository Pattern), then you could create a database stub that will return dummy data (or in memory data) until you are ready to plug in the actual EF framework.
如果您使用松散耦合实现了代码(请参阅存储库模式),那么您可以创建一个数据库存根,它将返回虚拟数据(或内存数据),直到您准备插入实际的EF框架。
This is generally good practice to create a clean separation of concerns.
这通常是良好的做法,以创建一个清晰的关注点分离。
#2
0
This sounds like a candidate for an SOA implementation, rather than having the windows forms app communicate directly with the web application:
这听起来像是SOA实现的候选者,而不是让Windows窗体应用程序直接与Web应用程序通信:
#1
2
If you have implemented your code with loose coupling (See the Repository Pattern), then you could create a database stub that will return dummy data (or in memory data) until you are ready to plug in the actual EF framework.
如果您使用松散耦合实现了代码(请参阅存储库模式),那么您可以创建一个数据库存根,它将返回虚拟数据(或内存数据),直到您准备插入实际的EF框架。
This is generally good practice to create a clean separation of concerns.
这通常是良好的做法,以创建一个清晰的关注点分离。
#2
0
This sounds like a candidate for an SOA implementation, rather than having the windows forms app communicate directly with the web application:
这听起来像是SOA实现的候选者,而不是让Windows窗体应用程序直接与Web应用程序通信: