xxxxxxxxxx
SQL expert for optimization and queries.
By Dmitry Khanukov
xxxxxxxxxx
Hi try the below tool to convert it
https://www.linqpad.net/
http://www.sqltolinq.com/
sql to linq
xxxxxxxxxx
use chatgpt to convert SQL to linq
https://chat.openai.com/chat
xxxxxxxxxx
<h1>Your <span style="color: var(--primary-color);">success</span> journey starts with us!</h1>
xxxxxxxxxx
"Select [Supplier Name] as Supplier_Name,MIN(Invoice_ID) as Invoice_ID, MIN(LogDated) as LogDated," +
"IIF(MIN(CAST([Traning Locked] as Nvarchar(1)))=1,'True','False') As[Training_Locked],"+
"Sum(IIF([OCR Exception] IS NOT NULL, 1, 0)) as [With_OCR_Exception],"+
"Sum(IIF([OCR Exception] IS NULL, 1, 0)) as [Without_OCR_Exception],"+
"COUNT([Invoice_ID]) as [Total],"+
"CAST((Sum(IIF([OCR Exception] IS not NULL, 1, 0)) * 100.0 / Count([Invoice_ID]))/100.0 as decimal(10, 3)) as [Percent]"+
"from[dbo].[qry_AllInvoiceOCRException] where AutomationStatus like '%Completed%' and ([Supplier Name] != '' or[Supplier Name] is not null)"+
"Group By[Supplier Name]"
xxxxxxxxxx
SELECT MarketingEmailSchedule.id as MarketingID,MarketingEmailSchedule.MarketingGroupSourceId,MarketingEmailSchedule.MarketingGroupId
,MarketingEmailSchedule.MarketingTemplateId,MarketingEmailSchedule.Subject,MarketingEmailSchedule.SendAsEmailId,MarketingEmailSchedule.ScheduledBy,MarketingEmailSchedule.ScheduledDate,GeneratedEmailHeader.Id as EmailHeaderId
FROM GeneratedEmailHeader JOIN MarketingEmailSchedule
ON GeneratedEmailHeader.MarketingEmailScheduleId = MARKETINGEMAILSCHEDULE.ID
join GeneratedEmail on GeneratedEmail.GeneratedEmailHeaderId = GeneratedEmailHeader.Id
where GeneratedEmailHeader.EmailGeneratedCount=GeneratedEmailHeader.SuccessfulEmailcount
select * from MarketingEmailSchedule
select * from GeneratedEmail
select * from GeneratedEmailHeader
xxxxxxxxxx
select * from VendorTicket (nolock) where IncidentID in (select IncidentID from Incident (nolock) where ClosedDate is null) and VendorID!=3 order by TicketID
xxxxxxxxxx
select category_name,permission_name,trp.add_date from template_role_permissions trp
inner join template_categories tc on trp.category_id=tc.id
inner join template_permissions tp on trp.permission_id=tp.id
where role_id=2
xxxxxxxxxx
from location in _context.Businessunit
where request.locationId.Contains(location.Id)
join client in _context.Businessunit on location.Parentbusinessunitid equals client.Id
join building in _context.Area on location.AddressId equals building.AddressId
where building.Appcategoryname == "Building" && building.IsEnable == true
join floor in _context.Area on building.Id equals floor.Parentareaid
where floor.Appcategoryname == "Floor" && building.IsEnable == true
join department in _context.Area on floor.Id equals department.Parentareaid
where department.Appcategoryname == "Department" && building.IsEnable == true
join equipment in _context.Equipment on department.Id equals equipment.Areaid
join device in _context.Device on equipment.Id equals device.Equipmentid
where device.IsEnable == true
select new
{
deviceId = device.Id,
deviceName = device.Devicename,
deviceNummber = device.DeviceNumber,
isConnected = device.IsConnected,
lastConnected = device.LastConnected,
lastSprayCycle = device.LastActualCommunicatedAt,
location_name = location.Name,
customer = client.Name,
building_name = building.AreaName,
floor_name = floor.AreaName,
department_name = department.AreaName,
}