In the realm of web development, achieving optimal performance is a constant pursuit. Leveraging caching effectively is a cornerstone in this endeavor, particularly with the robust capabilities offered by .NET Core. We'll explore practical implementation examples alongside best practices for .NET Core caching to demystify the process and empower developers. Understanding Caching in .NET Core: Before implementing, let's grasp the essence of caching in .NET Core. Caching involves storing frequently accessed data in memory, thereby reducing retrieval time and enhancing application responsiveness. .NET Core provides diverse mechanisms like in-memory caching, distributed caching, and response caching to cater to different scenarios. 1. Choosing the Right Mechanism: Let's begin with a simple example of in-memory caching. Suppose we have a method that fetches user details from a database: using Microsoft.Extensions.Caching.Memory; public class UserService { private readonly I...
For Those who have problem using string_split function in SQL Server 2008R2 CREATE FUNCTION dbo.string_split ( @stringToSplit VARCHAR(MAX), @separator VARCHAR(MAX) ) RETURNS @returnList TABLE ([value] [nvarchar] (500)) AS BEGIN DECLARE @name NVARCHAR(255) DECLARE @pos INT WHILE CHARINDEX(@separator, @stringToSplit) > 0 BEGIN SELECT @pos = CHARINDEX(@separator, @stringToSplit) SELECT @name = SUBSTRING(@stringToSplit, 1, @pos-1) INSERT INTO @returnList SELECT @name SELECT @stringToSplit = SUBSTRING(@stringToSplit, @pos+1, LEN(@stringToSplit)-@pos) END INSERT INTO @returnList SELECT @stringToSplit RETURN END
Though its a rare situation when we need to know the number of columns in a table. You can get the number of columns information for a particular table by running the following query on SQL Server SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_catalog = ' Your_Database_Name ' AND table_name = ' Your_Table_Name ' Good luck!
Comments
Post a Comment