DistinctBy in Linq (Find Distinct object by Property)

public class Size { public string Name { get; set; } public int Height { get; set; } public int Width { get; set; } } Consider that we have Size Class for advertisement which is having Heigth, Width and Name as property in it. Now Requirement is I have to find out the all product with distinct Name values. Size[] adv = { new Size { Name = “Leaderboard”, Height = 90, Width = 728 }, new Size { Name = “Large Rectangle”, Height = 280, Width = 336…

Dynamic Pivot Linq C#

I have the following collection / table Category Type Detail CostAuto Hybrid AC 80Auto Hybrid Sunroof 100Auto Standard AC 120Motorcycle Standard Radio 60 Is there a way with linq to get this to pivot to look like this? Category Type AC Radio Sunroof Auto Hybrid 80 0 100 Auto Standard 120 0 0Motorcycle Standard 0 60 0 use the let keyword to generate a key for use with the group by clause like so: var query = from item in list let key = new { Category = item.Category, Type…

Linqer (SQL to Linq converter)

Linqer is a SQL to LINQ conversion tool. It helps learning LINQ and convert existing SQL statements. Not every SQL statement can be converted to LINQ, but Linqer covers many different types of SQL expressions. Linqer supports both .NET languages – C# and Visual Basic. Because LINQ is a part of the C# and VB languages, it is sensitive to data type conversion. Linqer performs required type castings in the produced LINQ statements. It can convert the most usable SQL Server functions. The full list of supported MSSQL functions can…

How to Export Data to Excel in Blazor

In this new post, I’m going to show how to export data to Excel in Blazor WebAssembly or Server. Creating and exporting data to Excel file is one of the frequently used feature in web apps. First, for creating an export in Excel, I will use a free library that is a NuGet package. ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API. So, you can download the full source…

Working with CarouselView in Xamarin Forms

microsoft xamarin heros c# iOS Android UWP

Xamarin.Forms code runs on multiple platforms – each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app. CarouselView CarouselView is available in Xamarin.Forms 4.3. However, it is currently experimental and can only be used by adding the following line of code to your AppDelegate class on iOS, or to your MainActivity class on Android, before calling Forms.Init: Prerequisites Visual Studio…