Skip to content

Instantly share code, notes, and snippets.

@mirmostafa
Last active April 21, 2022 09:05
Show Gist options
  • Save mirmostafa/04361c074ec397ebc3476bee21ce4a3a to your computer and use it in GitHub Desktop.
Save mirmostafa/04361c074ec397ebc3476bee21ce4a3a to your computer and use it in GitHub Desktop.
From SQL Interpolated String
var dbResult = await this._readDbContext.ProductCategories.FromSqlInterpolated($@"
SELECT TOP 1 *
FROM [biz].[ProductCategories] t
WHERE NOT EXISTS (SELECT 1
FROM [biz].[ProductCategories]
WHERE ParentProductCategoryId = t.ProductCategoryId)
AND t.ProductCategoryId = {parameters.CategoryId} AND MerchantId = {merchantId}")
.AsNoTracking().FirstOrDefaultAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment