Dies ist mysql query:LINQ to SQL-Gruppe Durch die Verwendung und Reihenfolge von Graf
SELECT count(PVersion), PVersion
FROM [Products].[dbo].[Active_Details]
group by PVersion
order by count(PVersion);
Was wird seine LINQ to SQL sein.
Dies ist mysql query:LINQ to SQL-Gruppe Durch die Verwendung und Reihenfolge von Graf
SELECT count(PVersion), PVersion
FROM [Products].[dbo].[Active_Details]
group by PVersion
order by count(PVersion);
Was wird seine LINQ to SQL sein.
Sollte eine Gruppe in sein:
var product = (
from p in yourContext.Active_Details
group p by p.PVersion into pgroup
select new { VersionCount= pgroup.Count(), pgroup.Key }
).OrderBy(x=>x.VersionCount);
Hier ist ein MSDN Resource mit Beispielen
Versuchen Sie folgendes:
var product =
from p in yourContext.Active_Details
group p by p.PVersion into pgroup
let count = pgroup.Count()
orderby count
select new { Count = count, PVersion = pgroup.Key };
SELECT count(ProductVersion), ProductVersion , ProductID , SubProductID
FROM [do-not-delete-accounts].[dbo].[Activation_Details]
group by ProductVersion,ProductID,SubProductID
order by count(ProductVersion);
var query =
from p in yourContext.Activation_Details
group p by new
{
ProductVersion = p.ProductVersion,
ProductID = p.ProductID,
SubProductID = p.SubProductID
}
into pgroup
let count = pgroup.Count()
orderby count
select new
{
Count = count,
ProductVersion = pgroup.Key.ProductVersion,
ProductID = pgroup.Key.ProductID,
SubProductID = pgroup.Key.SubProductID
};
Vielen Dank. Eine weitere Sache, ich will, dass Ich möchte auch die anderen Spalten der Tabelle zugreifen, wie PID, SPID. Aber diese Abfrage nicht funktioniert, Wie kann ich das? –
bitte einen Kommentar, anstatt das Hinzufügen einer Antwort hinzuzufügen. Youll hat mir die SQL-Abfrage zeigen, die Sie im Auge haben als das, was Sie fragen, mit Aggregatfunktionen nicht möglich. –
Dies ist meine SQL-Abfrage: SELECT count (Product), Product, ProductID, SubProductID FROM [do-not-löschen-Konten] [dbo] [Activation_Details] Gruppe von Product, ProductID, SubProductID Reihenfolge von count (Product).. ; was wird sein Linq zu sql. –
Vielen Dank für Ihre Antwort, aber ich bin nicht in der Lage diese –
zugreifen Frage nach Ordnung nach, siehe auch meine Lösung. –