Reputation: 6514
After typing the following into 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 ...
I encounter a formatting problem when I enter the closing brace. Specifically, the text editor reformats the spaces in my linq query so that I end up with,
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 ...
}
Is it possible to change something in the formattings settings for Visual Studio to prevent the spaces in my linq query from being automatically deleted? I've tried Googling this, and I've looked through the Tools -> Options window of Visual Studio but wasn't able to find anything. Hopefully, I just overlooked something...
Many thanks in advance!
Upvotes: 5
Views: 2005
Reputation: 2267
In VS, go to Tools->Options, then Text Editor->C#->Formatting->General. Uncheck at least the first two checkboxes on this page. That will prevent VS from automatically formatting your code. However, there is no way to disable autoformat only for LINQ queries.
Upvotes: 4