I have such SQL which select, group and order Url field from Statistic table. getDomain is stored function. I am trying to rewrite this SQL to Linq without any luck. Please someone explain how to do that?
SELECT dbo.getDomain(Url) as url
FROM Statistic
GROUP BY dbo.getDomain(Url)
HAVING COUNT(Url) > 1
ORDER BY COUNT(Url)
First you have to define your UDF in the .DBML file that contains other tables and procedures definitions. Then you can Call any UDF function inline within your LINQ query Like this:
var results = from s in dbo.Statistic
groub s by dbo.getDomain(s.url) into g
where g.Count() > 1
orderby g.Count() ascending
select new
{
URL = dbo.getDomain(g.Key)
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With