Category: .NET
C# Interactive Window · Wiki doc
The C# Interactive Window provides a fast and iterative way to learn APIs, experiment with code snippets, and test methods by giving immediate feedback on what an expression will return or what an API call does.
The C# Interactive Window is a read-eval-print-loop (REPL) with advanced editor support. It supports features like IntelliSense as well as the ability to redefine functions & classes. After entering a code snippet–which can contain class and function definitions at top-level along with statements–the code executes directly. This means you no longer need to open a project, define a namespace, define a
Main
method, add aConsole.WriteLine()
call to output your result, and add aConsole.ReadLine()
call in order to play with code. In other words, say goodbye to ConsoleApp137 or whatever ridiculously high number your Console Apps default to today!
.NET C# to SQL Server Data Types Mapping table
SQL Server and the .NET Framework are based on different type systems. For example, the .NET Framework Decimal structure has a maximum scale of 28, whereas the SQL Server decimal and numeric data types have a maximum scale of 38.
Source: SQL Server Data Type Mappings
IEnumerable VS IQueryable
While query data from database, IQueryable execute select query on server side with all filters (e.g SQL select statement on database server). IEnumerable filters the data on client side. (in memory in application)
IEnumerable Example
- MyDataContext dc = new MyDataContext ();
- IEnumerable<Employee> list = dc.Employees.Where(p => p.Name.StartsWith(“S”));
- list = list.Take<Employee>(10);
Generated SQL statements of above query will be :
- SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
- WHERE [t0].[EmpName] LIKE @p0
Notice that in this query “top 10” is missing since IEnumerable filters records on client side
IQueryable Example
- MyDataContext dc = new MyDataContext ();
- IQueryable<Employee> list = dc.Employees.Where(p => p.Name.StartsWith(“S”));
- list = list.Take<Employee>(10);
Generated SQL statements of above query will be :
- SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
- WHERE [t0].[EmpName] LIKE @p0
Notice that in this query “top 10” is exist since IQueryable executes query in SQL server with all filters.
Source: IEnumerable VS IQueryable
Troy Hunt: Working with 154 million records on Azure Table Storage – the story of “Have I been pwned?”
Setting up and using Azure Table Storage in a simple way:
Be Sure With Azure .NET – Azure Table Storage (Part 1) – CodeProject
For this next article in the series, were going to be looking at Microsoft’ Azure’s Table Storage service.
Source: Be Sure With Azure .NET – Azure Table Storage (Part 1) – CodeProject
Strongly named assemblies in .NET explained
When the assembly is strongly-named, a “hash” is constructed from the contents of the assembly, and the hash is encrypted with the private key. Then this signed hash is placed in the assembly along with the public key from the .snk.
Later on, when someone needs to verify the integrity of the strongly-named assembly, they build a hash of the assembly’s contents, and use the public key from the assembly to decrypt the hash that came with the assembly – if the two hashes match, the assembly verification passes.
It’s important to be able to verify assemblies in this way to ensure that nobody swaps out an assembly for a malicious one that will subvert the whole application. This is why non-strong-named assemblies aren’t trusted in the same way that strongly-named assemblies are, so they can’t be placed in the GAC. Also, there’s a chain of trust – you can’t generate a strongly-named assembly that references non-strongly-named assemblies.
LINQ to CSV library – CodeProject
Fluent Assertions
Fluentassertions : Fluent Assertions is a set of .NET extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style test. We currently use it in all our internal and client projects, and it is used in many open-source projects. It runs on .NET 3.5, 4.0 and 4.5 (Desktop and Windows Store), Silverlight 4 and 5 and Windows Phone 7.5. And it supports the unit test frameworks NUnit, XUnit, MBUnit, Gallio and MSpec.
Source: Fluentassertions