News

Microsoft Open Sources .NET 5 C# Language Extension for SQL Server

Microsoft has open sourced a .NET 5 C# Language Extension for SQL Server, allowing developers to work with relational data in the company's flagship programming language.

The new tool joins similar extensions the company has open sourced over the past year or so for other languages, all taking advantage of a new kind of Language Extensions architecture, a SQL Server feature used for executing external code. While such code execution is isolated from the core engine processes, it is fully integrated with SQL Server query execution.

Component Architecture
[Click on image for larger view.] Component Architecture (source: Microsoft).

Microsoft says Language Extensions provides advantages such as:

  • Data security. Bringing external language execution closer to the source of data avoids insecure data movement.
  • Speed. Databases are optimized for set-based operations.
  • Ease of deployment and integration. SQL Server is the central point of operations for many other data management tasks and applications. By using data in the database, you ensure that the data used by the language extension is consistent and up-to-date.

After previously open sourcing tools for Java and R/Python last year, the .NET Core CSharp Language Extension is now on GitHub.

In the SQL Server Language Extensions scheme, any supported external language can be run by calling a stored procedure, with the results being returned as tabular data directly to SQL Server so it can easily use the external language from any application that can send a SQL query and handle the results. In the new tool, that's done with a DataFrame, which stores data as a collection of columns.

"This extension is yet another example of using the developed programming language extensibility architecture which provides integration with a new type of language extension," said Nikita Takru, program manager, Azure Data Team, in a Sept. 8 blog post. "This latest architecture allows customers to have the freedom to use existing SQL Server tables which they can pass to a C# application as a DataFrame.

"Then, they can perform operations in C#, use the rich libraries, and obtain back a result set. One of the reasons to use C# is to reuse existing customer C# code, calculations, logic, or extensive libraries that provide functionality which you cannot get in T-SQL. We encourage developers to use the .NET 5 C# Language Extension and build on it."

Possible use case advantages include:

  • Data cleaning.
  • Fast data querying.
  • Any processing in C# can now occur through a DataFrame.
  • Customers are not limited to the T-SQL language surface area.
  • C# application development teams that leverage SQL Server as backend storage can now even embed C# code in stored procedures which enables pushing business logic down into the database for better performance.
  • Avoid unnecessary data movement and latency when data must be retrieved from SQL Server and moved into the app tier to do the business logic processing.

By studying the publicly documented Extensibility Framework API for SQL Server and the tool's source code on the above-linked GitHub repo, Takru said community developers can continue to develop and contribute additional programming language extensions.

Other resources to help learn about the new offering and such language extensions in general include a Regex Sample available on GitHub that shows how to create a .NET Core C# program that receives two columns (ID and text) from SQL Server and a regular expression as an input parameter. The class returns two columns back to SQL Server (ID and text).

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events