-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed as not planned
Labels
Description
Per the documentation when you use multiple TagWith calls it is supposed to put an extra newline without comment marks (--) between them. The actual behavior is that is does not include a newline, making it impossible to parse tags unless you can assume that none of them are multiline.
Test Case:
var test = db.MyEntity
.TagWith("Test 1")
.TagWith(@"Test
2")
.ToArray();
Expected:
-- Test 1
-- Test
-- 2
SELECT [m].[Value] FROM [dbo].[MyEntity] AS [m]
Actual:
-- Test 1
-- Test
-- 2
SELECT [m].[Value] FROM [dbo].[MyEntity] AS [m]
Also, I would like to submit a request to add a parsed collection of tags to the CommandEndEventData. It could be added with a method similar to this (assuming the above bug is fixed).
IEnumerable<string> ParseTags(string script)
{
var sb = new StringBuilder();
var writingTag = false;
foreach (var line in script.Split(Environment.NewLine))
{
if (line.StartsWith("-- "))
{
writingTag = true;
sb.AppendLine(line[3..]);
continue;
}
if (writingTag)
{
writingTag = false;
yield return sb.ToString();
sb.Clear();
continue;
}
break;
}
Reactions are currently unavailable