3 ms·
Here's very cool example of what compiler as service can do: let's say you want extend SQL so that you can write C# expressions in SELECT like this: SELECT M
by sytelus 13y ago
Here's very cool example of what compiler as service can do: let's say you want extend SQL so that you can write C# expressions in SELECT like this:
SELECT MyClass1.Method1(ColumnA, Math.Round(ColumnB))
FROM Table1
Another example is you can extend your scripting language so that user can use full power of Linq.
So in otherwords, you can extend any of your little languages so that you can mix C# in it. Considering C# supports tons of functional features, Linq, anonymous types, dynamic types etc this can really beef up host language.
- noblethrasher 13y agoI thought that Roslyn expressly did not support extending the language.
- taspeotis 13y agoMy understanding is that you use Roslyn to use C# anywhere. It can parse expressions and compile and execute them. E.g. If you're writing a BASIC interpreter: 10 PRINT "Hello World" 20 CSHARP "Console.WriteLine(42);" 30 GOTO 10 You call Roslyn on line 2 with the expression to parse and execute.
- Guvante 13y agoRoslyn expressly does not support accepting the entire string that he provided. So if you want SQL wrapping C#, Roslyn won't support it until (and if) it supports SQLCLR. However what Roslyn does support is "transform this snippet for me", which is useful if you know the boundary between your code and code it cares about.
- taspeotis 13y agoFor what it's worth if you set up your SQLCLR assemblies right, that line of Transact-SQL can run just fine now, on SQL Server 2005 and later.