NOTE. . This seems to be a problem with the compiler that was used with SSDT projects, apparently it was fixed in RC 2017. My problem is similar to that described here.
I have code that does not allow me to write it as a member of a function with an expression. In short, I want to do this:
void foo() => bar();
But the IDE throws a tantrum and requires me to write it like this:
void foo() { bar(); }
I mean, these are two extra characters, but I'm not sure why he complains, the errors also make no sense. This gives me the following 3 errors:
- CS0000 :; Expected,
- CS0000: The method must have a return type.
- CS0000: ID expected.
The full code is as follows.
public static void foo() => bar("some param");
static void bar(string myParam) {
#, . .
VS 2015 4.6.1
:
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
public partial class Triggers
{
private const string ConnectionString = "context connection = true";
private const string ReadInsertedTable = @"
SELECT ID,
(
SELECT *
FROM inserted AS b
WHERE a.ID = b.ID
FOR XML RAW, ELEMENTS XSINIL
)
FROM inserted AS a
";
[SqlTrigger(Name = "Person_Insert", Target = "Person", Event = "FOR INSERT")]
public static void Person_Insert() => AuditInsert(TableName);
private const string TableName = "Person";
private static void AuditInsert(string tableName)
{
using (var readConnection = new SqlConnection(ConnectionString))
using (var writeConnection = new SqlConnection(ConnectionString))
{
using (var readCommand = new SqlCommand(ReadInsertedTable, readConnection))
{
readConnection.Open();
using (var reader = readCommand.ExecuteReader())
{
SqlContext.Pipe.Send((reader));
}
}
}
}
}

: msbuild, Visual Studio.