我想根据以下标准从数据库中提取记录:
我已经尝试了以下但是因为我在LINQ中不擅长而遇到错误。如果您也可以在纯SQL中编写它,我将不胜感激。
var transQuery = from t in db.TransactionsLogDbSet
where (t.TransactionType == TransactionType.PurchaseOfShares)
|| (t.TransactionType == TransactionType.TransferOfShares)
|| (t.TransactionType == TransactionType.BonusSharesDeclared)
group t by t.Transholder_ID into groupedTable
select (from t1 in groupedTable
orderby t1.TransLog_Date
descending
select t1).FirstOrDefault();
答案 0 :(得分:0)
var transQuery = (from t in db.TransactionsLogDbSet
where (t.TransactionType == TransactionType.PurchaseOfShares)
|| (t.TransactionType == TransactionType.TransferOfShares)
|| (t.TransactionType == TransactionType.BonusSharesDeclared)
orderby t.TransLog_Date
group t by t.Transholder_ID into groupedTable
select new { TransLog_ShareBalance = groupedTable.Key}).FirstOrDefault();