我已經打破了我的腦海裏嘗試使用XPO寫下一MSSQL查詢:的DevExpress XPO與子查詢
SELECT Gate.Name, grp.maxDate as 'Latest pass', a.Type, a.ReceivedTime as 'Imported at'
FROM Access AS a INNER JOIN
(SELECT GateId, MAX(OpenTime) AS maxDate
FROM Access
GROUP BY GateId) AS grp ON a.GateId = grp.GateId AND a.OpenTime = grp.maxDate INNER JOIN
Gate ON a.GateId = Gate.ID
order by Gate.ID
我Access表中有大約2條磨記錄,但它只有40個不同GATEID的。我要選擇各門線,這將是這樣的:
GateName 的OpenTime 類型 在
進口... .................................................. ...............................
Supergate 20/09/2013 21/09/2013
Ultragate 19/09/2013 22/09/2013
我訪問類看起來是這樣的:
public partial class Access : XPLiteObject
{
Gate fGateId;
[Association(@"AccessReferencesGate")]
public Gate GateId
{
get { return fGateId; }
set { SetPropertyValue<Gate>("GateId", ref fGateId, value); }
}
DateTime fOpenTime;
public DateTime OpenTime
{
get { return fOpenTime; }
set { SetPropertyValue<DateTime>("OpenTime", ref fOpenTime, value); }
}
byte fType;
public byte Type
{
get { return fType; }
set { SetPropertyValue<byte>("Type", ref fType, value); }
}
DateTime fReceivedTime;
public DateTime ReceivedTime
{
get { return fReceivedTime; }
set { SetPropertyValue<DateTime>("ReceivedTime", ref fReceivedTime, value); }
}
int fID;
[Key(true)]
public int ID
{
get { return fID; }
set { SetPropertyValue<int>("ID", ref fID, value); }
}
public Access(Session session) : base(session) { }
}
我的門類:
public partial class Gate : XPLiteObject
{
int fID;
[Key(true)]
public int ID
{
get { return fID; }
set { SetPropertyValue<int>("ID", ref fID, value); }
}
string fName;
[Size(20)]
public string Name
{
get { return fName; }
set { SetPropertyValue<string>("Name", ref fName, value); }
}
}
[Association(@"AccessReferencesGate", typeof(Access))]
public XPCollection<Access> AccessCollection { get { return GetCollection<Access>("AccessCollection"); } }
public Gate(Session session) : base(session) { }
}
任何答案,甚至RTFM鏈接將不勝感激!從DevExpress的支持中心
感謝您的幫助,但我認爲在Access錶行的2個百萬(增長)將這很慢。無論如何,我在DevExpress論壇上得到了一個可行的解決方案,將它發佈在 –
以下。是的,使用XPView也可以,但我希望生成的SQL查詢與我的答案和你的答案相似。 – shamp00