简体   繁体   English

SubSonic-类库项目?

[英]SubSonic - Class Library Project?

In the SubSonic docs it lists: 在SubSonic文档中,它列出了:

o By default, the Tool generates insert and update code that uses System.Web.HttpContext.Current.User.Identity.Name and System.Threading.Thread.CurrentPrincipal.Identity.Name. o默认情况下,该工具生成使用System.Web.HttpContext.Current.User.Identity.Name和System.Threading.Thread.CurrentPrincipal.Identity.Name的插入和更新代码。 Some generated methods may also make use of System.Web classes. 一些生成的方法也可能使用System.Web类。 If you don't want to have to add a reference to System.Web in your project, you will have to provide your own templates. 如果您不想在项目中添加对System.Web的引用,则必须提供自己的模板。

I tried to creat a SubSonic DAL of type C# Class Library. 我试图创建C#类库类型的SubSonic DAL。 Of course, the files generate, however an error is thrown during build time: 当然,文件会生成,但是在构建期间会引发错误:

*The type or namespace name 'HttpContext' does not exist ...*

("Is there a separate template available for creating a generic class library DAL that does not include System.Web references?" ? Where : How to modify the existing templates) (“是否有单独的模板可用于创建不包含System.Web引用的通用类库DAL?”哪里:如何修改现有模板)

Thanks! 谢谢!

("Is there a separate template available for creating a generic class library DAL that does not include System.Web references?" ? Where : How to modify the existing templates (“是否有单独的模板可用于创建不包含System.Web引用的通用类库DAL?”?位置:如何修改现有模板

You need to have a reference to System.Web for SubSonic version 2 or 3 to work. 您需要对System.Web进行引用才能使SubSonic版本2或3正常工作。 You can just add that to your library project and it'll work. 您可以将其添加到您的库项目中,它将起作用。

Wow, talk about over-complicating things. 哇,谈论过于复杂的事情。 I just added a ref to System.Web - got it. 我刚刚向System.Web添加了一个参考-做到了。 For some reason, I thought I'd have to change the .aspx template. 由于某些原因,我认为我必须更改.aspx模板。

Oops, and thanks. 糟糕,谢谢。

Version 2 has a subdirectory with .aspx files that you can modify to change the template code (you just need to change the path in your app.config file to point to new dir of aspx files). 版本2包含一个包含.aspx文件的子目录,您可以对其进行修改以更改模板代码(您只需更改app.config文件中的路径以指向aspx文件的新目录)。

Version 3 has .tt files that you modify. 版本3具有您修改的.tt文件。

Information for how to modify both versions of the templates are on the SubSonic project site. SubSonic项目站点上提供了有关如何修改两个版本的模板的信息。

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

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