简体   繁体   English

从库项目C#访问项目类

[英]Access to the project classes from library project C#

I have the following question. 我有以下问题。

I am currently working on a C # project and need to create some library projects, but at the time of creating these projects I was presented with the following scenario: I need access to the classes in the main project from within the library projects Since my data base access layer is in the main project, I'm looking for a way so that I don't have to add this into every library project. 我目前正在研究C#项目,需要创建一些库项目,但是在创建这些项目时,我遇到以下情形:我需要从库项目中访问主项目中的类数据库访问层位于主项目中,我正在寻找一种方法,从而不必将其添加到每个库项目中。

Really only needed to execute SELECT statements. 真的只需要执行SELECT语句。 I use ADO.NET to execute all transactions over the data base. 我使用ADO.NET在数据库上执行所有事务。

Any help will be really useful. 任何帮助将非常有用。

Thanks for your time. 谢谢你的时间。

It is not a good idea to reference the executable/main project in the library project. 在库项目中引用可执行文件/主项目不是一个好主意。 It should be vice versa. 反之亦然。

The Library project should be independent of the application's platform. 库项目应独立于应用程序的平台。 What you should do is to extract the data access code in another library project. 您应该做的是在另一个库项目中提取数据访问代码。 That way you will be able to access it in other libraries/projects. 这样,您将可以在其他库/项目中访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM