This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.Json; | |
namespace SomeLibrary.Classes; | |
/// <summary> | |
/// Provides utility methods for validating the presence of specific sections | |
/// in the "appsettings.json" configuration file. | |
/// </summary> | |
/// <remarks> | |
/// This class is designed to assist in ensuring that critical configuration | |
/// sections, such as "EntityConfiguration" and "ConnectionStrings", are |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
/// <summary> | |
/// Joins the elements of the specified <see cref="IEnumerable{T}"/> into a single string, | |
/// separating them with the specified separator, and appending a specified token before the last element. | |
/// </summary> | |
/// <typeparam name="T">The type of the elements in the collection.</typeparam> | |
/// <param name="sender">The collection of elements to join.</param> | |
/// <param name="separator"> | |
/// The string to use as a separator between elements. Defaults to ", " if not specified. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class DataOperations | |
{ | |
public static IEnumerable<Customer> GetCustomerDetails() | |
{ | |
using IDbConnection connection = new SqlConnection(DataConnections.Instance.MainConnection); | |
var customerDictionary = new Dictionary<int, Customer>(); | |
var customers = connection.Query<Customer, Contact, Country, ContactType, Customer>( | |
SqlStatements.CustomerWithContacts(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Numerics; | |
namespace Extensions; | |
public static class GenericINumberExtensions | |
{ | |
public static T[] Merge<T>(this T[] container, T[] T1) where T : INumber<T> | |
=> [.. container, .. T1]; | |
public static T[] Merge<T>(this T[] container, T[] T1, T[] T2) where T : INumber<T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using NewStuffApp.Models; | |
namespace NewStuffApp.Classes; | |
/// <summary> | |
/// Provides a set of static methods for iterating over collections of various types | |
/// (e.g., strings, integers, and Person) and performing operations on them. | |
/// </summary> | |
internal class Params |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Helpers | |
{ | |
/// <summary> | |
/// Retrieves the names of all entities that implement a specified interface type. | |
/// </summary> | |
/// <typeparam name="T"> | |
/// The interface type to search for. Must be a class type and an interface. | |
/// </typeparam> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var members = MemberOperations.MembersList(); | |
List<GroupedMember> groups = MemberOperations.GroupedMembers(members); | |
foreach (GroupedMember groupMember in groups) | |
{ | |
Console.WriteLine(groupMember); | |
foreach (Member member in groupMember.Lists) | |
{ | |
Console.WriteLine($"\t{member.Id,-3}{member.Active}"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE tempdb | |
GO | |
-- Prepare the scene | |
CREATE TABLE #ChristmasScene | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.name AS TableName, | |
p.rows AS [RowCount] | |
FROM sys.tables t | |
INNER JOIN sys.partitions p | |
ON t.object_id = p.object_id | |
WHERE p.index_id IN ( 0, 1 ) | |
ORDER BY p.rows DESC, | |
t.name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* var pastDate = new Date('2014-10-01T02:30'); | |
* var message = fromNow(pastDate); | |
* //=> '2 days ago' | |
* | |
* @param {Date} Native JavaScript Date object | |
* @return {string} | |
*/ | |
function fromNow(date) { | |
var seconds = Math.floor((new Date() - date) / 1000); |