简体   繁体   English

如何在Visual Studio 2015中预览资源文件内容?

[英]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: 我唯一的规定是:

  1. I'd like to avoid mingling my SQL with my C# if at all possible. 我想尽可能避免将SQL与C#混合在一起。
  2. I need to be able to write highly-specialized queries, so an ORM is not the answer. 我需要能够编写高度专业的查询,因此ORM并不是答案。
  3. Prefer not to use stored procedures (or at least not be confined to them). 最好不要使用存储过程(或至少不限于它们)。

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.

相关问题 如何在Visual Studio 2015中使用资源文件 - How to use a resource file in Visual Studio 2015 在我的 VS 扩展中,如何在 Visual Studio 2015/2017 中以编程方式预览文件? - In my VS extension, how can I programmatically preview a file in Visual Studio 2015/2017? 更改Visual Studio 2015扩展中项目中文件ProjectItem的内容吗? - Change the contents of a file ProjectItem within a Project in a Visual Studio 2015 Extension? 如何将“CodeLens 引用”窗口的内容保存到 Visual Studio 2015 中的文件中? - How can I save the contents of the “CodeLens References” window to a file in Visual Studio 2015? 未在Visual Studio 2015中为可移植类创建资源文件包装器 - Resource file wrapper not created for Portable class in Visual Studio 2015 凉亭在Visual Studio 2015预览中不起作用 - bower not working in Visual Studio 2015 Preview Visual Studio 2015 Preview中缺少报告模板 - Reporting Template is missing in Visual Studio 2015 Preview Visual Studio 2015 XAML资源字典错误 - Visual Studio 2015 XAML Resource Dictionary Error 如何在visual studio中添加资源文件 - How to add a resource file in visual studio Visual Studio 2015中缺少ASP.net 5预览模板 - ASP.net 5 preview templates are missed in Visual Studio 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM