I'm having a hard time finding anything about executing a raw query, I have no idea how to translate this to LINQ or if it is even possible.
I have ContactRecords in my DBSet but I don't really want that I guess, I just need to do multiple counts.. raw query..
I need to do multiple COUNTs and use a DB function i created "usp_Parse_domain_name_v5":
This is the Query I'm trying to execute in my DOT NET CORE app:
SELECT
dbo.usp_Parse_domain_name_v5(ContactRecord.URL),
COUNT(ContactRecord.ContactId) AS TOTAL_IMPRESSIONS,
COUNT(DISTINCT ContactAttribute.ContactAttributeValue) AS UNIQUE_IMPRESSIONS,
COUNT(DISTINCT LEADS.LEAD_ID) AS CONVERSIONS,
MAX(convert(varchar(10), ContactRecord.CallStartDateTime, 102)) AS 'DATE'
FROM
ContactAttribute
LEFT JOIN ContactRecord ON ContactRecord.ContactId = ContactAttribute.ContactId AND ContactAttribute.ContactAttributeName = 'IP'
LEFT JOIN LEADS
ON LEADS.LEAD_ID = ContactRecord.ContactId
AND LEADS.EMAIL IS NOT NULL AND LEADS.PHONENUMBER IS NOT NULL
AND LEADS.FIRSTNAME IS NOT NULL AND LEADS.LASTNAME IS NOT NULL
WHERE
convert(varchar(10), ContactRecord.CallStartDateTime, 102) = '2019.05.16'
GROUP BY
dbo.usp_Parse_domain_name_v5(URL)
ORDER BY
COUNT(ContactRecord.ContactId) DESC;