在 Visual Studio 2010 中键入以下内容后,
using(var myEntities = new MyEntities())
{
IQueryable<Employee> employees =
from e in myEntities.Employees
where e.Name == name &&
e.Password == hasher.ComputeHash(password)
select e;
... Code left out for simplicity ...
输入右大括号时遇到格式问题。具体来说,文本编辑器重新格式化我的 linq 查询中的空格,以便我最终得到,
using(var myEntities = new MyEntities())
{
IQueryable<Employee> employees =
from e in myEntities.Employees
where e.Name == name &&
e.Password == hasher.ComputeHash(password)
select e;
... Code left out for simplicity ...
}
是否可以更改 Visual Studio 的格式设置中的某些内容以防止我的 linq 查询中的空格被自动删除?我试过谷歌搜索这个,我已经浏览了 Visual Studio 的工具 -> 选项窗口,但找不到任何东西。希望我只是忽略了一些东西......
提前谢谢了!
最佳答案
在 VS 中,转到 Tools->Options,然后 Text Editor->C#->Formatting->General。至少取消选中此页面上的前两个复选框。这将阻止 VS 自动格式化您的代码。但是,无法仅对 LINQ 查询禁用自动格式化。
关于visual-studio - Visual Studio 中的 Linq 查询格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7372165/