اشتراک‌ها
پروژه ApiBoilerPlate برای ساخت پروژه های ASP.NET Core APIs

A simple yet organized project template for building ASP.NET Core APIs in .NET Core 3.1

Tools and Frameworks Used

  • .NET Core 3.1
  • ASP.NET Core - For building RESTful APIs
  • Dapper - For data access.
  • AutoMapper - For mapping entity models to DTOs.
  • AutoWrapper - For handling request Exceptions and consistent HTTP response format.
  • AutoWrapper.Server - For unwrapping the Result attribute from AutoWrapper's ApiResponse output.
  • Swashbuckle.AspNetCore - For securing API documentation.
  • FluentValidation.AspNetCore - For Model validations
  • Serilog.AspNetCore - For logging capabilities
  • IdentityServer4.AccessTokenValidation - For JWT Authentication handling
  • Microsoft.Extensions.Http.Polly - For handling HttpClient Resilience and Transient fault-handling
  • AspNetCoreRateLimit - For controlling the rate of requests that clients can make to an external API based on IP address or client ID.
  • AspNetCore.Diagnostics.HealthChecks - For performing health checks
  • Microsoft.AspNetCore.Diagnostics.HealthChecks - For getting the results of Health Checks in the application
  • AspNetCore.HealthChecks.UI - For Health Status visualization
  • xUnit and Moq - For unit testing.  


پروژه ApiBoilerPlate برای ساخت پروژه های ASP.NET Core APIs
اشتراک‌ها
نگاهی به آینده WebAssembly

The future of WebAssembly - A look at upcoming features and proposals

WebAssembly is a performance optimised virtual machine that was shipped in all four major browsers earlier this year. It is a nascent technology and the current version is very much an MVP (minimum viable product). This blog post takes a look at the WebAssembly roadmap and the features it might be gain in the near future.

I’ll try to keep this blog post relatively high-level, so I’ll skip over some of the more technical proposals, instead focusing on what they might mean for languages that target WebAssembly. 

نگاهی به آینده WebAssembly
اشتراک‌ها
بررسی چالش‌های استفاده از UTC و TimeZones در برنامه‌های تحت وب مبتنی‌بر ‪.NET

Using UTC in Applications

Using UTC dates for data is a pretty common and necessary practice but it definitely adds some complexity when managing dates as you always have to remember to properly adjust dates. For display purposes this is pretty straight forward, but for query operations there’s a bit of mental overhead to ensure your date math adds up properly.

No easy solutions, but I hope this post and some of the helpers make life a little easier for you – I know they do for me. 

بررسی چالش‌های استفاده از UTC و TimeZones در برنامه‌های تحت وب مبتنی‌بر ‪.NET
نظرات مطالب
روش استفاده‌ی صحیح از HttpClient در برنامه‌های دات نت
یک نکته‌ی تکمیلی

به همراه NET Core 2.1.، یک HttpClientFactory توکار توسط مایکروسافت ارائه شده‌است:

به این ترتیب برای مثال جهت کار با یک آدرس مشخص، می‌توان تنظیمات آن‌را یکبار در آغاز برنامه ثبت کرد:
public void ConfigureServices(IServiceCollection services)
{
    services.AddHttpClient("github", c =>
    {
        c.BaseAddress = new Uri("https://api.github.com/");
        c.DefaultRequestHeaders.Add("User-Agent", "HttpClientFactory-Sample"); // Github requires a user-agent
    });
    services.AddHttpClient();
}
و بعد برای استفاده‌ی سراسری از آن توسط سیستم ترزیق وابستگی‌ها، می‌توان به صورت زیر عمل کرد:
IHttpClientFactory _httpClientFactory;
public MyController(IHttpClientFactory httpClientFactory)
{
    _httpClientFactory = httpClientFactory;
}
public IActionResult Index()
{
    //This client doesn’t have any special configuration applied
    var defaultClient = _httpClientFactory.CreateClient();
    //This client has the header and base address configured for the “github” client above.
    var gitHubClient = _httpClientFactory.CreateClient("github");
    return View();
}
مطالب
پیاده سازی عملیات صفحه بندی (paging) در sql server

در خیلی مواقع ملاحظه میشود که برای نمایش تعدادی از رکوردهای یک جدول در پایگاه داده، کل مقادیر موجود درآن توسط یک دستور select به دست می‌آید و صفحه‌بندی خروجی، به کنترلهای موجود سپرده میشود. اگر پایگاه داده ما دارای تعداد زیادی رکورد باشد، آن موقع است که دچار مشکل می‌شویم. فرض کنید به طور همزمان ۵ نفر (که تعداد زیادی نیستند) از برنامه ما که شامل ۱۰۰۰۰۰ سطر داده میباشد استفاده کنند و در هر صفحه، ۱۰ رکورد نمایش داده شود و صفحه‌بندی ما از نوع معقولی نباشد. در این صورت به جای اینکه با ۵×۱۰ رکورد داده را بارگزاری کنیم، ۵×۱۰۰۰۰۰ رکورد یعنی ۵۰۰۰۰۰ رکورد را برای به دست آوردن ۵۰ رکورد بارگزاری میکنیم. در زیر روشی شرح داده میشود که توسط آن، این سربار اضافه از روی برنامه و سرورهای مربوطه حذف شود. به stored procedure و توضیحات مربوط به آن توجه فرمایید :

CREATE PROCEDURE sp_PagedItems
(
 @Page int,
 @RecsPerPage int
)
AS

-- We don't want to return the # of rows inserted
-- into our temporary table, so turn NOCOUNT ON
SET NOCOUNT ON


--Create a temporary table
CREATE TABLE #TempItems
(
ID int IDENTITY,
Name varchar(50),
Price currency
)


-- Insert the rows from tblItems into the temp. table
INSERT INTO #TempItems (Name, Price)
SELECT Name,Price FROM tblItem ORDER BY Price

-- Find out the first and last record we want
DECLARE @FirstRec int, @LastRec int
SELECT @FirstRec = (@Page - 1) * @RecsPerPage
SELECT @LastRec = (@Page * @RecsPerPage + 1)

-- Now, return the set of paged records, plus, an indiciation of we
-- have more records or not!
SELECT *,
MoreRecords =
(
 SELECT COUNT(*)
 FROM #TempItems TI
 WHERE TI.ID >= @LastRec
)
FROM #TempItems
WHERE ID > @FirstRec AND ID < @LastRec


-- Turn NOCOUNT back OFF
SET NOCOUNT OFF
در این کد دو پارامتر از نوع integer تعریف میکنیم. اول پارامتر @Page که مربوط به شماره صفحه‌ای می‌باشد که قصد دارید آن‌را بارگزاری نمایید. دومین پارامتر با نام @RecsPerPage تعداد رکوردهایی است که هر بار میخواهید بارگزاری شوند. مثلا اگر میخواهید هر بار ۱۵ عدد از رکوردها را نمایش دهید، این مقدار را باید برابر ۱۵ قرار دهیم. در مرحله بعد یک جدول موقت با نام #TempItems ساخته شده است که به طور موقت مقادیری را در حافظه نگه میدارد. نکته کلیدی که جلوتر از آن استفاده شده، ستون با نام ID است که از نوع auto-increment بوده و روی جدول موقت تعریف شده است. این ستون شناسه هر سطر را در خود نگه میدارد که به صورت اتوماتیک بالا میرود و جزء لاینفکی از این نوع paging میباشد. پس از آن جدول موقت را توسط رکوردهای جدول واقعی با نام tblItem توسط دستور select پر میکنیم.

در مرحله بعد شماره اولین و آخرین سطر مورد نظر را بر اساس پارامترهای ورودی محاسبه کرده و در متغیرهای @FirstRec و @LastRec می‌ریزیم.
برای استفاده از این کد فقط کافیست که پارامترهای ورودی را مقداردهی نمایید. مثلا اگر میخواهید در یک کنترل Grid از آن استفاده کنید باید ابتدا یک کوئری داشته باشید که تعداد کل سطرها را به شما بدهد و بر اساس این مقدار تعداد صفحات مورد نظر را به دست آورید. پس از آن با کلیک روی هر کدام از شماره صفحات آن را به عنوان مقدار به پارامتر مورد نظر بفرستید و از آن لذت ببرید. 

اشتراک‌ها
کتاب رایگان Implementing Domain Driven Design

This is a practical guide for implementing Domain Driven Design (DDD). While the implementation details are based on the ABP Framework infrastructure, the basic concepts, principles and models can be applied to any solution, even if it is not a .NET solution.  

کتاب رایگان Implementing Domain Driven Design
اشتراک‌ها
Rider 2018.3.1 منتشر شد

Rider 2018.3.1 comes with fixes for:

Several issues in the debugger: RIDER-23087, RIDER-22932, RIDER-22770, RIDER-22887, and RIDER-22873.
Broken NuGet window after searching for “mongo” text (RIDER-22927).
Endless “Retrieving properties…” progress bar for Project Properties (RIDER-22924).
Inability to activate the dotTrace plugin via the License Server (RIDER-22876).
The “Failed to get the list of simulators” error on getting a list of iOS simulators (RIDER-22878).
The issue where a .jar setting file couldn’t be imported to Rider 2018.3 (RIDER-22823).
The misplaced position of inline parameter name hints (RIDER-22452).
 

Rider 2018.3.1 منتشر شد
اشتراک‌ها
پروژه OrcaMDF
A C# parser for MDF files
Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance  
پروژه OrcaMDF
اشتراک‌ها
استراتژی های پیشرفته استقرار نرم افزار

استراتژی‌های پیشرفته‌ی استقرار نرم افزار که در Continuous Deployment و DevOps کاربرد فراوانی دارند: 

Blue-Green Deployment Strategy

Canary Deployment Strategy

Dark Launch Strategy

A/B Deployment Strategy

استراتژی های پیشرفته استقرار نرم افزار