Thursday, March 21, 2024

Reference article to Add dynamic meta tags

 


https://blog.logrocket.com/adding-dynamic-meta-tags-react-app-without-ssr/


https://www.javatpoint.com/add-page-title-and-meta-tags-using-angular-9or8-seo


https://medium.com/@baunov/dynamic-meta-tags-for-angular-app-part-1-dc5957af202c

Thursday, February 1, 2024

SQL Server Database Installation Fail Windows 11

Credits and Thanks to  https://blog.nimblepros.com/blogs/sql-server-windows-11-fiasco/

If you’ve run into an issue with LocalDB or SQL Server where the process fails to start and you see an error message about misaligned log IOs, you’re not alone. This issue can be particularly frustrating, especially if you’re not sure where to start in terms of troubleshooting. Here’s what I did to fix the problem and get LocalDB working again.

First things first, you’ll want to check the SQL Server log files to see if there are any clues as to what might be causing the issue. If like me you notice a message stating something like “there have been 256 misaligned log IOs which required falling back to synchronous IO”, you’re in luck. Well, you’re in luck in the sense that you’re reading the right article and hopefully we can get you out of this mess. If you don’t see this message, but something entirely different, sorry friend, it’s back to googling for you.

Ok, here’s what’s most likely going on. You have a modern SSD and you either:

  1. Tried installing SQL Server (or localDB) on a Windows 11 machine.
  2. Installed SQL Server (or localDB) on a Windows 10 machine, then upgraded to Windows 11.

Maybe you’re running into problems trying to install SQL Server or just starting it up. Either way, if you’re seeing the “misaligned log IOs” error message, the root cause is the same: Windows 11 doesn’t behave the same way as Windows 10 when it comes to disk sector sizes on modern SSDs.

From PowerShell, as an administrator, run the following command:

 New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device" -Name "ForcedPhysicalSectorSizeInBytes" -PropertyType MultiString -Force -Value "* 4095"


https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/database-file-operations/troubleshoot-os-4kb-disk-sector-size

Wednesday, May 31, 2023

Basic MySQL to LINQ conversion using chatbot group by , distinct , left join


 Convert following MySQL query to Linq query in .net core entity framework

ChatGPT

To convert a MySQL

User
Select teamuser.id, teamduration.createddate, teamduration.startdate ,teamduration.enddate , teamuser.categoryId, teamuser.subcategoryId, supervisorUserId , categorymaster.name, subcategorymaster.name as subcategory , su.user_name as supervisor , ru.user_name Reporting, u.user_name as teammember from teamuser tu inner join teamduration td on teamuser.id = td.teamUserId inner join usermaster su on su.id = td.supervisoruserid left join usermaster ru on ru.id = td.reporterUserId left join usermaster u on u.id = tu.userId left join categorymaster cm on cm.id = tu.categoryId left join subcategorymaster scm on scm.id = tu.subcategoryId
ChatGPT

To convert the given MySQL query to a LINQ query in .NET Core Entity Framework, you can use the LINQ syntax and Entity Framework's DbSet properties. Here's how you can write the LINQ query:

csharp
var query = from tu in dbContext.TeamUsers join td in dbContext.TeamDurations on tu.Id equals td.TeamUserId join su in dbContext.UserMasters on td.SupervisorUserId equals su.Id join ru in dbContext.UserMasters on td.ReporterUserId equals ru.Id into ruGroup from ru in ruGroup.DefaultIfEmpty() join u in dbContext.UserMasters on tu.UserId equals u.Id into uGroup from u in uGroup.DefaultIfEmpty() join cm in dbContext.CategoryMasters on tu.CategoryId equals cm.Id into cmGroup from cm in cmGroup.DefaultIfEmpty() join scm in dbContext.SubcategoryMasters on tu.SubcategoryId equals scm.Id into scmGroup from scm in scmGroup.DefaultIfEmpty() select new { tu.Id, td.CreatedDate, td.StartDate, td.EndDate, tu.CategoryId, tu.SubcategoryId, SupervisorUserId = td.SupervisorUserId, CategoryName = cm.Name, SubcategoryName = scm.Name, SupervisorName = su.UserName, ReportingName = ru.UserName, TeamMemberName = u.UserName }; var results = query.ToList();

Note that you need to replace dbContext with your actual instance of the Entity Framework's DbContext class, and the TeamUsers, TeamDurations, UserMasters, CategoryMasters, and SubcategoryMasters properties with the corresponding DbSet properties in your DbContext class.

The LINQ query uses the join clause to perform inner joins and left joins between the tables. The into keyword and DefaultIfEmpty() method are used to perform left joins. The select clause creates a new anonymous type with the desired properties from the joined tables.

Finally, the ToList() method executes the query and retrieves the results into a list.

User
How to select {CategoryName , SubcategoryName , SupervisorName } from above results grouped or distinct values
ChatGPT

To select distinct or grouped values for CategoryName, SubcategoryName, and SupervisorName from the results obtained in the previous query, you can modify the LINQ query as follows:

csharp
var distinctResults = query .Select(x => new { x.CategoryName, x.SubcategoryName, x.SupervisorName }) .Distinct() .ToList();

In this modified query, the Select() method is used to project the desired properties (CategoryName, SubcategoryName, and SupervisorName) from the results. The Distinct() method is then applied to eliminate duplicate rows based on the selected properties. Finally, the ToList() method is used to execute the query and retrieve the distinct results into a list.

The distinctResults list will contain distinct combinations of CategoryName, SubcategoryName, and SupervisorName from the original query results.

User
How to select using group by?
ChatGPT

To select using the GROUP BY clause in LINQ, you can modify the previous LINQ query to include the group keyword. Here's an example of how you can select using GROUP BY:

csharp
var groupedResults = query .GroupBy(x => new { x.CategoryName, x.SubcategoryName, x.SupervisorName }) .Select(group => new { CategoryName = group.Key.CategoryName, SubcategoryName = group.Key.SubcategoryName, SupervisorName = group.Key.SupervisorName }) .ToList();

In this modified query, the GroupBy() method is used to group the results based on the selected properties (CategoryName, SubcategoryName, and SupervisorName). The Select() method is then used to project the grouped properties into a new anonymous type with the desired property names. Finally, the ToList() method executes the query and retrieves the grouped results into a list.

The groupedResults list will contain distinct combinations of CategoryName, SubcategoryName, and SupervisorName based on the GROUP BY operation.