我无法从Google搜索中获得明确的指导。我有一个名为的表transaction,我想针对外键进行分组BatchID和排序descending。
表定义
[TTransactionID] INT IDENTITY (1, 1) NOT NULL,
[BatchID] INT NULL,
[CardID] INT NULL,
[UserID] INT NULL,
[TransactionDateTime] DATETIME NOT NULL,
[TransactionStatus] VARCHAR (11) NOT NULL,
CONSTRAINT [PK_Transactions] PRIMARY KEY CLUSTERED ([TTransactionID] ASC),
CONSTRAINT [FK_Transactions_Cards] FOREIGN KEY ([CardID]) REFERENCES [dbo].[Cards] ([CardID]),
CONSTRAINT [FK_Transactions_Users] FOREIGN KEY ([UserID]) REFERENCES [dbo].[Users] ([UserID]) NOT FOR REPLICATION
这是我第五次尝试的代码
var TransactionList = db.Transactions
.GroupBy(x => new { x.BatchID })
.Select(x => x.ToList()).ToList();
int index = 0;
foreach (var item in TransactionList)
{
Response.Write( string.Format("[{0}] - {1}", index, item) );
index++;
}
当我运行上面的代码时。我在浏览器上收到以下消息。我被困在这里,之后我不知道该怎么办。
System.Collections.Generic.List`1[SECardDistribution.Models.Transaction]
请告知谢谢
一只名叫tom的猫
海绵宝宝撒
慕侠2389804
相关分类