Skip to content

Instantly share code, notes, and snippets.

View mjebrahimi's full-sized avatar
🎯
Focusing

Mohammad Ebrahimi mjebrahimi

🎯
Focusing
View GitHub Profile
@mjebrahimi
mjebrahimi / Benchmark.cs
Last active December 3, 2022 11:52
BenchmarkDotNet example with most useful attributes and features
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Running;
using EasyCompressor;
using System;
using System.Collections.Generic;
using System.IO;
@mjebrahimi
mjebrahimi / github-actions.yaml
Last active April 15, 2020 14:33
Gtihub action .yaml file for .NET Core libraries
name: .NET Core
on:
push:
paths-ignore:
- 'readme.md'
pull_request:
paths-ignore:
- 'readme.md'
@mjebrahimi
mjebrahimi / Sample.csproj
Created April 8, 2020 16:06
.csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.1;netstandard2.0;netstandard2.1;net45;net461;netcoreapp2.1</TargetFrameworks>
<AssemblyName>EasyCompressor</AssemblyName>
<PackageId>EasyCompressor</PackageId>
<Title>EasyCompressor</Title>
<Product>EasyCompressor</Product>
<Version>1.0.0</Version>
<PackageVersion>1.0.0</PackageVersion>
@mjebrahimi
mjebrahimi / Global.asax.cs
Created June 5, 2020 05:18 — forked from davidfowl/Global.asax.cs
ASP.NET MVC and ServiceCollection sample
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.Extensions.DependencyInjection;
using WebApplication16;
using WebApplication16.Controllers;
@mjebrahimi
mjebrahimi / README.md
Last active December 12, 2020 18:23
چالش های متداول طراحی مدل ها در دیتابیس Mongo

چالش های متداول طراحی مدل ها در دیتابیس Mongo

یکی از مهمترین مزایای دیتابیس های nosql (مخصوصا داکیومنت بیس ها مانند مونگو) امکان embed کردن مقادیر مرتبط داخل یک داکیومنت هست که باعث میشه بتونیم عملیات جوین (که بسیار هزینه بر هست) رو حذف کنیم که موجب افزایش پرفرمنس عملیات واکشی میشه

مشکلی که اکثر برنامه نویس های sql کار به هنگام مهاجرت به mongo با اون مواجه میشن اینه که همچنان میخوان با دید sql ای به قضیه نگاه کنن.

اگر قرار باشه با دید sql با mongo برخورد کنیم همون بهتر که از یه دیتابیس sql ایی مانند sql server استفاده کنیم که هم قابلیت relation داره، هم با ef سازگار هست و هم بدلیل وجود امکان navigation property ها، امکان کوئری نویسی ساده تر رو داره و نیاز به جوین نویسی های پیچیده نداره

@mjebrahimi
mjebrahimi / EF Core - FromSql - ExecuteSqlCommand.md
Created March 19, 2021 18:16
EF Core - FromSql - ExecuteSqlCommand

Executing Raw SQL Queries

Entity Framework Core provides mechanisms for executing raw SQL queries directly against the database in circumstances where you cannot use LINQ to represent the query (e.g. a Full Text Search), if the generated SQL is not efficient enough, if you want to make use of existing stored procedures, or if you just prefer to write your own queries in SQL.

Entity Framework Core provides mechanisms

  • FromSql
    • FromSqlRaw (EF Core 3.0)
@mjebrahimi
mjebrahimi / TypedDictionary.cs
Last active February 3, 2022 16:06
High Performance Generic Type Dictionary
// -----------------------------------------------------------------------
// <copyright file="TypedDictionary.cs" company="Asynkron AB">
// Copyright (C) 2015-2021 Asynkron AB All rights reserved
// </copyright>
// -----------------------------------------------------------------------
using System;
using System.Threading;
namespace Proto.Utils
{
@mjebrahimi
mjebrahimi / FieldInfer.cs
Last active May 7, 2021 19:48
An idea to use strongly typed `Suffix` method in elasticsearch NEST library.
Field postField = elasticClient.Infer.Field<Blog>(p => p.Post); //Field.Name: "post"
Field tagsField = postField.Suffix<Post>(p => p.Tags); //Field.Name: "post.tags"
Field tagsIdField = tagsField.Suffix<Tag>(p => p.Id); //Field.Name: "post.tags.id"
public class FieldInfer : Field
{
public Inferrer Infer { get; set; }
public FieldInfer(Inferrer inferrer, string name) : base(name)
{
Infer = inferrer;