[英]How to preview resource file contents in Visual Studio 2015?
I'm using a resource file to organize custom SQL for my DAL. 我正在使用资源文件来为我的DAL组织自定义SQL。 For a basic example, my repository class (using Dapper) looks like:
对于一个基本示例,我的存储库类(使用Dapper)如下所示:
public class FooRepository : IFooRepository {
public Foo GetById(int id) {
using (var con = await GetConnection()) {
var foo = (await con.QueryAsync<Foo>(
Sql.Foos.GetById,
new { FooID = id }
)).SingleOrDefault();
return foo;
}
}
}
In this case, Sql.Foos.GetById
is a reference to a resource file, the contents of which are pure SQL, such as: 在这种情况下,
Sql.Foos.GetById
是对资源文件的引用,其内容是纯SQL,例如:
SELECT * FROM Foo WHERE FooID = @FooID;
However, there doesn't seem to be an easy way to preview the contents of the query. 但是,似乎没有一种预览查询内容的简单方法。 The auto-generated summary for the resource spills out the first few lines (which is all that is needed for simple queries), but doesn't get updated as resources are changed, and for larger files with complex queries this is unhelpful to say the least.
自动生成的资源摘要会溢出前几行(这是简单查询所需的全部内容),但不会随着资源的更改而更新,对于具有复杂查询的较大文件,这无益于说最小。
Is there a better way to preview the contents of my SQL resource files (even if it involves storing my queries differently)? 有没有更好的方法来预览我的SQL资源文件的内容(即使它涉及以不同方式存储我的查询)? My only stipulations are:
我唯一的规定是:
You should open up the ResourceFileName.Designer.cs
from your solution explorer. 您应该从解决方案
ResourceFileName.Designer.cs
打开ResourceFileName.Designer.cs
。
In there you will find all the get methods for your imported sqls and there you can also set the summary manually. 在这里,您将找到导入的sql的所有get方法,在这里您还可以手动设置摘要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.