复合主键“过滤”在GridControl中 [英] Composite Primary Key "Filtering" in GridControl

查看:60
本文介绍了复合主键“过滤”在GridControl中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的表:

I have a table that look like this:

CREATE TABLE [dbo].[Table](
	[IDRow] [int] NOT NULL,
	[Revision] [int] NOT NULL,
	[EntryDate] [datetime] NULL,
	[UserID] [int] NULL,
	[Title] [nvarchar](100) NULL,
	[TypeID] [nvarchar](10) NULL,
	[Tags] [nvarchar](max) NULL,
	[PriorityID] [nvarchar](10) NULL,
	[DeadlineDate] [datetime] NULL,
	[Description] [nvarchar](max) NULL,
 CONSTRAINT [PK__Table__A6C7A1C4145C0A3F] PRIMARY KEY CLUSTERED 
(
	[IDRow] ASC,
	[Revision] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO



它由一个复合主键组成,用于作为单个列显示给用户:


It consists of a composite primary key which is meant to be shown to the user as a single column:

CAST(IDRow AS VARCHAR(4)) + ''-'' + CAST(Revision AS VARCHAR(3)) AS ItemNumber





所以现在我想要pe rhaps将一些SQL添加到Table_SelectAll过程中,它只选择版本号最大的行。有和将会有更多的行,如1-0,1-1,1-2,1-3 ......我想只显示1-3行。



在SELECT查询中解决它或者在填充gridControl时可能在代码隐藏中更好吗?无论哪种方式,请帮助有效地做到这一点。

使用SQL Server 2008 R2,VS 2012和VB编码。



So now I want to perhaps add some SQL to the Table_SelectAll Procedure that it only selects the row with the greatest revision number. There are and will be more rows like 1-0, 1-1, 1-2, 1-3...and I want to show only the 1-3 row.

Is it better to solve it inside the SELECT query or maybe in the code-behind while filling the gridControl? Either ways, please help to do this efficiently.
Using SQL Server 2008 R2, VS 2012 and coding in VB.

推荐答案

我'如果可能的话,建议你这样做。原因是为什么从SQL Server返回更多数据只是为了以后过滤它?这只是更多的网络流量和内存,它将被扔掉。
I''d suggest you do this if possible sql side. The reason being why return more data from SQL Server just to filter it out later on? It''s just more network traffic and memory which is just going to get thrown away.


这篇关于复合主键“过滤”在GridControl中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆