Press "Enter" to skip to content

Category: Misc Languages

Translating Datasets in Power BI Premium

Kasper de Jonge shows how you can translate data in Power BI datasets if you’re using Premium:

One request that comes up a lot is to be able to provide translations for the tables and columns of your model (especially here in Europe). Up until now this was not possible in Power BI as there was no UI for it. The new XMLA read/write feature changed all of this. As you probably know in SSAS Tabular this is already possible. The new XMLA endpoint makes any Power BI dataset into a SSAS tabular model with most of its functionalities. So how do you use it in Power BI and add translations? In this blog post I will walk you through it.

Click through for a demo.

Comments closed

Pluralization with Entity Framework Core

Erik Ejlskov Jensen takes us through auto-pluralization with Entity Framework Core:

If you are using the EF Core console command dotnet ef dbcontext scaffold or Package Manager Console in Visual Studio Scaffold-DbContext, you can hook up pluralization via code in your project.

First you must add a reference to the Microsoft.EntityFrameworkCore.Design package from your startup project.

Click thorugh for a code sample.

Comments closed

Currying in Scala

Sarfaraz Hussain takes us through one of the most important concepts in functional languages:

Normally we write function and it seems like below:

def multiplySimple(a: Int, b: Int): Int = a * b

We declare a function with all the arguments needed inside a single parameter list.

In currying however, we can split this parameter list into multiple parameter lists.

def multiplyCurry(a: Int)(b: Int): Int = a * b

This doesn’t seem like much, but it does lead to partial application of functions and is one method for how we can have multiple inputs in a functional programming language when mathematical functions allow one input.

Comments closed

Java Extension for SQL Server Now Open Source

Nellie Gustafsson announces some exciting news:

Today, we’re thrilled to announce that we are open sourcing the Java language extension for SQL Server on GitHub.

This extension is the first example of using an evolved programming language extensibility architecture which allows integration with a new type of language extensions. This new architecture gives customers the freedom to bring their own runtime and execute programs using that runtime in SQL Server while leveraging the existing security and governance that the SQL Server programming language extensibility architecture provides.

This opens up the possibility for additional languages. .NET languages (C# and F#) would be a natural fit and languages like Go might have enough dedicated support to give this a try.

Comments closed

Generating Entity Framework Core Classes from a Database Project

Erik Ejlskov Jensen walks us through generating Entity Framework classes from a Visual Studio database project and from a .dacpac file:

EF Core Power Tools adds the ability to generate code directly from a Database project, without having to publish to a live database first, and having a SQL Server database engine running locally. It can also generate code from live SQL Server, Azure SQL DB, MySQL, Postgres and SQLite database. It has a large number of customization options – pluralization, renaming, file and name space choices and more, which is not available via the EF Core commands. And you do not have to install any design time libraries in your own project.

Read on for a demo of that as well as a dacpac reverse engineering tool.

Comments closed

Reading JSON in .NET from a DataTable

Hasan Savran ran into an issue parsing JSON data from SQL Server via .NET:

FOR JSON lets you return the data in JSON format. As you might know, SQL Server can return and query JSON documents, but It doesn’t have a special data type for JSON documents. You must store data as string in SQL Server. You can make SQL Server work like a NoSQL Database. Your web application can retrieve data as JSON document and you can use dynamic objects to make things flexible.

     Let’s see an example first, In the following example, I retrieve data as JSON document and send it to directly to my front-end as string. JavaScript parses it and generates a grid from it. It’s very flexible because there is no schema. Front-End will display whatever SQL Server returns. You can change query and without changing any code in the middle, your grid will display the data.

There are limitations in how much JSON gets generated on the buffer at a time, so click through to see how you can rebuild the entire JSON output for a large file.

Comments closed

Deconstructing Running Totals with M

Cedric Charlier shows how to turn a running total into a periodic series of events with M:

When dealing with time series, you should always check if your time series are event-based or cumulative. For a time series with a step of one day, an event-based time series will contain the count of events for a given day. A cumulative time series will contain the sum of the event of that day and of all the previous days! In this blog post I’ll explain how to transform a cumulative time series into an event-based.

Click through for the code. You can do this in T-SQL as well by subtracting the value from its LAG()-ged value.

Comments closed

Parameterization and Enumerable.Contains() with EF Core 3

Erik Ejlskov Jensen explains how we can prevent Entity Framework Core 3 from polluting the plan cache if we use Enumerable.Contains():

One of the many advantages of using a tool like Entity Framework Core is, that you are sure that the framework will generate properly parameterized SQL for you. This helps avoid SQL injection issues and avoids plan cache pollution. Unfortunately, EF Core currently falls short on that promise, when translating queries, where you supply a list of values to be matched against a column – Enumerable.Contains method – this is translated to a SQL Server IN operator

Click through for a setup of the problem as well as the solution.

Comments closed

Coding Tips for a Younger Self

Parvinder Nijjar has some good tips for less-experienced developers:

Always break a big problem into a series of small problems. Sometimes a big problem can feel daunting and be more difficult than it seems. Break the problem down into smaller blocks and then solve each block one at a time. It’s okay to skip a block and return to a previous block as it may give you clues to fixing the skipped block. In all honesty whilst coding the parts you can do a piece of divine inspiration will enable you to problem you couldn’t solve or you will enough code to show one of your more capable colleagues that you had tried to fix the issue and now this rubbish was there problem to fix.

I am basically at the point of self-parody in my love of functional programming languages, but this is one of those things FP really reinforces: bottom-up development and chaining together lots of little pieces to create big pieces. But there is good advice in here no matter what language you use.

Comments closed

Microsoft to Acquire npm via GitHub

Joab Jackson breaks the news:

Code repository service GitHub is in the process of acquiring the preeminent software registry for Node.js and JavaScript modules, npm, the two companies announced Monday.

GitHub plans to invest in npm’s infrastructure, with the hopes of bringing some much-needed modernization to the platform, GitHub CEO Nat Friedman promised in a blog post. It also may help free the rapidly-growing registry from the considerable financial and personnel turmoil that it has been inflicted with over the past few years.

I for one welcome leftpad by Microsoft.

Comments closed