skip to content
Relatively General .NET

Exploring the new AI chat template

by Andrew Lock

posted on: May 06, 2025

In this post I explore the new .NET AI Chat Web App template (currently in preview) and take a brief look at the implementation it provides…

RavenDB Storage Provider for Orleans

by Oren Eini

posted on: May 05, 2025

Orleans is a distributed computing framework for .NET. It allows you to build distributed systems with ease, taking upon itself all the state management, persistence, distribution, and concurrency.The core aspect in Orleans is the notion of a “grain” - a lightweight unit of computation & state. You can read more about it in Microsoft’s documentation, but I assume that if you are reading this post, you are already at least somewhat familiar with it.We now support using RavenDB as the backing store for grain persistence, reminders, and clustering. You can read the official announcement about the release here, and the docs covering how to use RavenDB & Microsoft Orleans.You can use RavenDB to persist and retrieve Orleans grain states, store Orleans timers and reminders, as well as manage Orleans cluster membership. RavenDB is well suited for this task because of its asynchronous nature, schema-less design, and the ability to automatically adjust itself to different loads on the fly.If you are using Orleans, or even just considering it, give it a spin with RavenDB. We would love your feedback.

StringComparison.InvariantCulture is not always invariant

by Gérald Barré

posted on: May 05, 2025

CultureInfo.InvariantCulture is not invariant for all operations. It is a special culture that is used for formatting and parsing operations that do not depend on any specific culture. For instance, this is well-suited to format values in order to persist them. However, it is not invariant for stri

RavenDB News

by Oren Eini

posted on: May 02, 2025

RavenDB is moving at quite a pace, and there is actually more stuff happening than I can find the time to talk about. I usually talk about the big-ticket items, but today I wanted to discuss some of what we like to call Quality of Life features.The sort of things that help smooth the entire process of using RavenDB - the difference between something that works and something polished. That is something I truly care about, so with a great sense of pride, let me walk you through some of the nicest things that you probably wouldn’t even notice that we are doing for you.RavenDB Node.js Client - v7.0 released (with Vector Search)We updated the RavenDB Node.js client to version 7.0, with the biggest item being explicit support for vector search queries from Node.js. You can now write queries like these:const docs = session.query<Product>({collection: "Products"}) .vectorSearch(x => x.withText("Name"), factory => factory.byText("italian food")) .all();This is the famous example of using RavenDB’s vector search to find pizza and pasta in your product catalog, utilizing vector search and automatic data embeddings.Converting automatic indexes to static indexesRavenDB has auto indexes. Send a query, and if there is no existing index to run the query, the query optimizer will generate one for you. That works quite amazingly well, but sometimes you want to use this automatic index as the basis for a static (user-defined) index. Now you can do that directly from the RavenDB Studio, like so:You can read the full details of the feature at the following link.RavenDB Cloud - Incidents History & Operational SuggestionsWe now expose the operational suggestions to you on the dashboard. The idea is that you can easily and proactively check the status of your instances and whether you need to take any action.You can also see what happened to your system in the past, including things that RavenDB’s system automatically recovered from without you needing to lift a finger.For example, take a look at this highly distressed system:As usual, I would appreciate any feedback you have on the new features.

Recording

by Oren Eini

posted on: April 30, 2025

Last week I did an hour long webinar showing AI integration in RavenDB. From vector search to RAG, from embedding generation to Gen AI inside of the database engine.Most of those features are already released, but I would really love your feedback on the Gen AI integration story (starts at around to 30 minutes mark in the video). Let me know what you think!

The null check that didn't check for nulls

by Oren Eini

posted on: April 28, 2025

I wrote the following code:if (_items is [var single]) { // no point invoking thread pool single.Run(); }And I was very proud of myself for writing such pretty and succinct C# code. Then I got a runtime error:I asked Grok about this because I did not expect this, and got the following reply:No, if (_items is [var single]) in C# does not match a null value. This pattern checks if _items is a single-element array and binds the element to single. If _items is null, the pattern match fails, and the condition evaluates to false.However, the output clearly disagreed with both Grok’s and my expectations. I decided to put that into SharpLab, which can quickly help identify what is going on behind the scenes for such syntax. You can see three versions of this check in the associated link.if(strs is [var s]) // no null check if(strs is [string s]) // if (s != null) if(strs is [{} s]) // if (s != null)Turns out that there is a distinction between a var pattern (allows null) and a non-var pattern. The third option is the non-null pattern, which does the same thing (but doesn’t require redundant type specification). Usually var vs. type is a readability distinction, but here we have a real difference in behavior. Note that when I asked the LLM about it, I got the wrong answer. Luckily, I could get a verified answer by just checking the compiler output, and only then head out to the C# spec to see if this is a compiler bug or just a misunderstanding.

PowerShell Script to rename .NET projects

by Gérald Barré

posted on: April 28, 2025

Renaming a .NET project is tedius. You have to rename the files and folders. You also have to replace the content in the files, such as namespace, or path in .sln files. Here's a PowerShell script that renames files and folders and replaces content in files:PowerShellcopy$ErrorActionPreference = "S