Skip to content

Instantly share code, notes, and snippets.

using System.Collections.Generic;
using System.Linq.Expressions;
namespace System.Linq
{
public static class QueryableHelper
{
public static IQueryable<TEntity> Search<TEntity>(this IQueryable<TEntity> query, string searchValue, params Expression<Func<TEntity, string>>[] propertiesToSearch)
{
if (string.IsNullOrEmpty(searchValue)) return query;
@martinandersen3d
martinandersen3d / Args.cs
Created November 5, 2022 22:52 — forked from josheinstein/Args.cs
Argument Validation Helper (C#)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
/// <summary>
/// Provides methods for checking method arguments for validity and throwing localizable exceptions for invalid
/// arguments or argument combinations.
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Globalization;
public static partial class StringExtensions
{
public static sbyte ToSByte(this string s)
{

using System;
using System.Linq;
using System.Text;
using System.Globalization;
namespace TextDataUtility
{
public static partial class StringExtensions
{
@martinandersen3d
martinandersen3d / Fundamentals---ORM.cs
Created October 7, 2022 10:49 — forked from bbrt3/Fundamentals---ORM.cs
Entity Framework Core
/*
ORM (Object-Relational Mapping) allows us to have a framework
for storing objects within relational databases and translating between
DATABASE-CODE communication.
What is ORM?
1. Object relational mapping is a technique for storing,
retrieving, updating and deleting (CRUD) from
an object-oriented program in a relational database.
2. Utilization of "data layer" to manage translation between the OO and relational
@martinandersen3d
martinandersen3d / Logic.cs
Created April 24, 2022 11:33 — forked from tams89/Logic.cs
NUnit TestCaseSource Async
using System;
using System.Threading;
namespace MT.Tests
{
/// <summary>
/// An object containing some information.
/// </summary>
public class Logic
{
@martinandersen3d
martinandersen3d / IntegrationTest.cs
Created April 24, 2022 01:12 — forked from Elfocrash/IntegrationTest.cs
ASP.NET Core Integration tests code from my video: https://www.youtube.com/watch?v=7roqteWLw4s
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Tweetbook.Contracts.V1;
using Tweetbook.Contracts.V1.Requests;
using Tweetbook.Contracts.V1.Responses;
@martinandersen3d
martinandersen3d / Converting NUnit to XUnit.md
Last active April 24, 2022 00:04 — forked from yetanotherchris/first-steps.md
Converting NUnit to XUnit
  • Get VS Code
  • Remove using NUnit.Framework;
  • Add using XUnit;
  • Replace all [Test] with [Fact]
  • Replace [SetUp] with a constructor
  • Replace Assert.That(actualValue, Is.EqualTo(value)); with Assert.Equal(expected, actual)
    • highlight Is.EqualTo(
    • Delete it
    • Select to the end of the line
  • Ctrl + X