When you do a project, you need to display the first few data from different groups in the same GridView
Several technical points:
1, data grouping, this method does not use GROUP by
2. Several query merge bindings with the same result format
3, take the query results before or after a number of data
public int Bindliftdata ()
{
int count = 0;
using (mysqlconnection conn = new Mysqlconnection (dbserver))
{
Frddata db = new Frddata (conn);
list<int> ids = new list<int> ();
var item = from I in db. Items
Join P in DB. Progs on I.progid equals p.id
where p.state = = 1 && i.type = = "Lift"
Select New {i.id};
bool IsFirst = true;
int FirstID = 0;
foreach (var i in item)
{
if (IsFirst)
{
FirstID = i.id;
IsFirst = false;
}
Else
Ids. ADD (i.id);
}
var q = (from I in DB. Items
Join L in DB. Lifts on i.id equals l.itemid
where i.id = = FirstID
L.id Descending
Select New {i.id, I.name, L.angle, I.stole, L.lift}). Take (3). ToList ();
foreach (var x in IDs)
{
var r = (from I in DB. Items
Join L in DB. Lifts on i.id equals l.itemid
where i.id = = X
L.id Descending
Select New {i.id, I.name, L.angle, I.stole, L.lift}). Take (3). ToList ();
Q.addrange (R);
}
Gvlift.datasource = q;
Count = Q.count;
}
return count;
}
GridView binds multiple data sources with the same format (data query merge)