I have a table called alerts and is related to a table called coin (coin can have many alerts)
I would like to return a list of alerts but also return a subquery count of how many alerts that coin has
Here is my query, I would love some feedback on how it can be improved.
context.Alerts .Include(x => x.Coin) .Where(x => !x.IsComplete) .OrderByDescending(x => x.CreatedDateUtc) .Take(topCount) .Select(x => new AlertDto(x, context.Alerts.Where(y => y.CoinId == x.CoinId && !y.IsComplete).Count())) .ToList();
Here is the sql generated code
It does one for the main alerts
exec sp_executesql N'SELECT TOP(@__p_0) [x].[AlertId], [x].[CoinId], [x].[CreatedDateUtc], [x].[EmailAddress], [x].[IsComplete], [x].[IsFake], [x].[IsUp], [x].[Threshold], [x].[ThresholdPercent], [x.Coin].[CoinId], [x.Coin].[Icon], [x.Coin].[LastPriceBtc], [x.Coin].[LastPriceUsd], [x.Coin].[LastUpdated], [x.Coin].[Name], [x.Coin].[Rank], [x.Coin].[Symbol] FROM [Alerts] AS [x] INNER JOIN [Coins] AS [x.Coin] ON [x].[CoinId] = [x.Coin].[CoinId] WHERE [x].[IsComplete] = 0 ORDER BY [x].[CreatedDateUtc] DESC',N'@__p_0 int',@__p_0=100
and a 100(topcount) more query db of these
exec sp_executesql N'SELECT COUNT(*) FROM [Alerts] AS [y0] WHERE ([y0].[CoinId] = @_outer_CoinId) AND ([y0].[IsComplete] = 0)',N'@_outer_CoinId int',@_outer_CoinId=864
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!