Skip to content

Instantly share code, notes, and snippets.

View MahdiKarimipour's full-sized avatar
🎯
Focusing

MK MahdiKarimipour

🎯
Focusing
  • TechnologyLeads
  • Sydney, Australia
View GitHub Profile
@MahdiKarimipour
MahdiKarimipour / pellerex-run-entity-framework-migration-using-external-sql-file.cs
Created July 3, 2022 11:19
Run Entity Framework Migrations using External SQL Files
public partial class FullAddressFullTextIndex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
string sql = GeneralFunctions.ReadSql(typeof(FullAddressFullTextIndex), "20220702124309_FullAddressFullTextIndex.sql");
migrationBuilder.Sql(sql, true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
@MahdiKarimipour
MahdiKarimipour / pellerex-create-sql-sever-full-text-index.sql
Created July 3, 2022 11:18
How to create Full-Text Index using SQL Server
CREATE FULLTEXT INDEX ON dbo.Addresses(FullAddress)
KEY INDEX PK_Addresses ON FTCAddress
WITH STOPLIST = OFF, CHANGE_TRACKING AUTO;
@MahdiKarimipour
MahdiKarimipour / pellerex-call-repository-to-fetch-full-text-query.cs
Created July 3, 2022 11:17
How to call Pellerex Repository to Fetch Full-Text Queries
public async Task<IEnumerable<AddressViewModel>> GetAddresses(string query)
{
var foundAddresses = await LocationApiRepository.AddressRepository.GetFullText(t => t.FullAddress, query)
.Select(c => new AddressViewModel()
{
Id = c.Id,
FullAddress = c.FullAddress,
})
.Take(30)
.ToListAsync();
@MahdiKarimipour
MahdiKarimipour / pellerex-run-full-text-queries.cs
Created July 3, 2022 11:14
How to Run Full-Text Queries using C# and Entity Framework
public IQueryable<Address> GetFullText(
Expression<Func<Address, string>> predicate,
string query,
int currentPage = 0,
int pageSize = 0)
{
if (pageSize == 0)
{
return Context.Addresses
.Where(e => EF.Functions.Contains(e.FullAddress, $"\"{query}\""));
@MahdiKarimipour
MahdiKarimipour / rekenix-seo-components.js
Created April 24, 2022 23:29
SEO Components used in Rekenix Foundation
<SEO
title={props.title}
location={props.location}
type={SeoConstants.Types.Article}
author={props.author}
authorTwitterUserName={props.authTwitterUserName}
description={props.description}
datePublished={props.datePublished}
dateModified={props.dateModified}
readTime={props.readTime}
@MahdiKarimipour
MahdiKarimipour / pellerex-azure-devops-get-project-groups-response.cs
Created April 9, 2022 08:11
Get Project Groups using Azure DevOps REST APIs
public class AzureDevOpsGetProjectGroupsResponseDto
{
public int count { get; set; }
public Value[] value { get; set; }
public class Value
{
public string subjectKind { get; set; }
public string description { get; set; }
public string domain { get; set; }
@MahdiKarimipour
MahdiKarimipour / pellerex-azure-devops-get-all-project-groups.cs
Created April 9, 2022 08:10
Get the List of All Project Groups using Azure DevOps APIs and Pellerex
var url = appSettings.AzureDevOpsSettings.GetProjectGroupsUrl
.Replace("{organisation}", organisation)
.Replace("{scopeDescriptor}", projectDescriptor);
var (result, response) = await apiCall.GetAsync<AzureDevOpsGetProjectGroupsResponseDto>(
url: url,
password: appSecrets.AzureDevOpsToken);
if (result.IsEmpty())
{
@MahdiKarimipour
MahdiKarimipour / pellerex-azure-devops-create-security-group-response-payload.cs
Created April 9, 2022 07:52
Response Payload to Create Azure DevOps Security Group
public class AzureDevOpsCreateGroupResponseDto
{
public string subjectKind { get; set; }
public string description { get; set; }
public string domain { get; set; }
public string principalName { get; set; }
public object mailAddress { get; set; }
public string origin { get; set; }
public string originId { get; set; }
public string displayName { get; set; }
@MahdiKarimipour
MahdiKarimipour / pellerex-azure-devops-create-security-group.cs
Created April 9, 2022 07:49
Create Security Group using Azure DevOps REST APIs
public async Task<(GroupViewModel, HttpStatusCode)> CreateGroup(GroupViewModel group, string scopeDescriptor)
{
var request = new AzureDevOpsCreateGroupRequestDto()
{
displayName = group.Name,
description = group.Description
};
var url = appSettings.AzureDevOpsSettings.CreateGroupUrl
.Replace("{organisation}", group.Organisation)
@MahdiKarimipour
MahdiKarimipour / pellerex-azure-devops-get-scope-descriptor.json
Created April 9, 2022 07:44
Get Project Scope Descriptor Using Azure DevOps
{
"value": "scp.MDU4....ZGNm",
"_links": {
"self": {
"href": "https://vssps.dev.azure.com/.../_apis/Graph/Descriptors/953d3623...aa0e770d"
},
"storageKey": {
"href": "https://vssps.dev.azure.com/.../_apis/Graph/StorageKeys/scp.MDU4YTU2N........ZGNm"
},
"subject": {