三层设计;排序和过滤基于对象的数据 [英] 3-tier design; sorting and filtering object-based data

查看:62
本文介绍了三层设计;排序和过滤基于对象的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我,原来是什么,三层设计鬼混。

在几个网站上,人们对使用非常热情自定义

dataobjects而不是datasets / -tables。

在尝试自己编写这样的图层时,我被困在如何获得

过滤或排序来自数据层的数据。


这就是我得到的:


对象

*类Marble

- MarbleID

- 颜色

- 尺寸


数据层

* SqlHelper - ExecuteNonQuery,ExecuteDataSet,ExecuteReader等。

* Marbles - int Insert(Marble m),bool更新(Marble m),

Marble [] ListAll, Marble []选择(int marbleID)


业务层

* Marble [] ListMarbles()

* bool UpdateMarble( int marbleID,字符串颜色,字符串大小)




我想通过使用property-name作为列来过滤结果

过滤器 上。这可能吗?如果不是......我应该如何从数据层请求过滤的

结果,而不必为每个可能的过滤器创建一个单独的成员

?是否可以在对象数组中对对象属性进行排序?


我希望你能理解我的问题....

TIA

解决方案

如果您希望在数据端执行此操作,您可以在ORDER BY子句中使用

到你的sql statemtent:


从someTable ORDER BY字段中选择*


如果你想在你的数据层中这样做,你有一个不同的

选项的数量,可能最简单的是让你的班级实现

IComparable系统界面:

http://msdn2.microsoft.com/en-us/library/4d7sx9hd.aspx


希望有所帮助!


Sjaakie写道:




我,原来是这样,三层设计鬼混。

在几个网站上,人们得到了回复我热衷于使用自定义

数据对象而不是数据集/ -tables。

在尝试自己编写这样的图层时,我被困在如何获得

从数据层过滤或排序数据。


这就是我得到的:


对象

*类大理石

- MarbleID

- 颜色

- 尺寸


数据层

* SqlHelper - ExecuteNonQuery,ExecuteDataSet,ExecuteReader等。

*大理石 - int插入(大理石m),bool更新(大理石m),

大理石[] ListAll,Marble []选择(int marbleID)


商务层

* Marble [] ListMarbles()

* bool UpdateMarble(int marbleID,字符串颜色,字符串大小)




我想通过使用property-name作为列来过滤结果

过滤器。这可能吗?如果不是......我应该如何从数据层请求过滤的

结果,而不必为每个可能的过滤器创建一个单独的成员

?是否可以在对象数组中对对象属性进行排序?


我希望你能理解我的问题....

TIA





如果您使用tsql作为后端数据库,那么请查看
http://www.sqlservercentral.com/colu。 ..terproblem.asp


对于强类型物品的分类,请检查

6/19/2006

高级IComparer //对多个值进行排序


http ://sholliday.spaces.live.com/

我还有一个分层示例(和1.1和2.0)


你需要看看那个

接受的SerializeOrder(或其类似的)代码和IDataReader


如果仔细观察,你会发现你可以重用(并重复使用)

序列化器..........

无论你创建IDataReader是什么/如何
。 ..


如果您没有使用tsql,那么您可以编写一个sql生成器代码....

动态创建sql语句

(比如,如果你正在使用访问权限)。

但我不是这个的忠实粉丝。




" Sjaakie" < ke ** @ secret.itwrote in message

news:45 ********************** @ news.xs4all.nl ...




我,原来是什么,愚弄3层设计。

在几个网站上,人们非常热衷于使用自定义的

数据对象而不是数据集/ -tables。

在尝试自己编写这些图层时我得到了坚持如何从数据层过滤或排序数据。


这就是我得到的:


物品

*类大理石

- MarbleID

- 颜色

- 尺寸


数据层

* SqlHelper - ExecuteNonQuery,ExecuteDataSet,ExecuteReader等。

* Marbles - int Insert(Marble m),bool更新(Marble) m),

Marble [] ListAll,Marble []选择(int marbleID)


商务层

*大理石[ ] ListMarbles()

* bool U. pdateMarble(int marbleID,字符串颜色,字符串大小)




我想使用property-name作为列来过滤结果

过滤。这可能吗?如果不是......我应该如何从数据层请求过滤的

结果,而不必为每个可能的过滤器创建一个单独的成员

?是否可以在对象数组中对对象属性进行排序?


我希望你能理解我的问题....

TIA



我知道sql方式处理这个,但我一直在寻找

类似于实现IComparable接口。我会深入研究它。

谢谢!


Sean Chambers写道:


如果您希望在数据端执行此操作,可以在ORDER BY子句中使用
到您的sql statemtent:


select * from someTable ORDER BY字段


如果您希望在数据层中执行此操作,您可以使用多种不同的
选项,最简单的方法是让您的类实现

IComparable系统界面:

http://msdn2.microsoft.com/en-us/library/4d7sx9hd.aspx


希望有所帮助!


Sjaakie写道:


>
我是,原来是什么,愚弄3-层设计。
在几个网站上,人们非常热衷于使用自定义数据对象而不是数据集/表。
Wh我试图自己编写这样的图层,我不知道如何从数据层中过滤或排序数据。

这就是我得到的:

对象
*类大理石
- MarbleID
- 颜色
- 大小

数据层
* SqlHelper - ExecuteNonQuery,ExecuteDataSet,ExecuteReader等。
*大理石 - int插入(大理石米),布尔更新(大理石米),
大理石[] ListAll,大理石[]选择(int marbleID)

业务层
* Marble [] ListMarbles()
* bool UpdateMarble(int marbleID,string color,string size)

将属性名称作为要过滤的列。这可能吗?如果不是......我应该如何从数据层请求过滤的结果,而不必为每个可能的过滤器创建一个单独的成员?是否可以在对象数组中对对象属性进行排序?

我希望你理解我的问题....
TIA


Hi,
I''m, what it turns out to be, fooling around with 3-tier design.
At several websites people get really enthusiastic about using custom
dataobjects instead of datasets/-tables.
While trying to write such layers myself I got stuck on how to get
filtered or sorted data from the data-layer.

This is what I got:

Objects
* class Marble
- MarbleID
- Color
- Size

Data-layer
* SqlHelper - ExecuteNonQuery, ExecuteDataSet, ExecuteReader etc.
* Marbles - int Insert(Marble m), bool Update(Marble m),
Marble[] ListAll, Marble[] Select(int marbleID)

Business-layer
* Marble[] ListMarbles()
* bool UpdateMarble(int marbleID, string color, string size)
etc.

I would like to filter results by using the property-name as column to
filter on. Is this possible? If not... how should I request a filtered
result from the data-layer, without having to create a seperate member
for every possible filter? And is it possible to sort object-properties
in an object-array?

I hope you understand my question....
TIA

解决方案

If you wish to do this on the data end, you could at an ORDER BY clause
onto your sql statemtent:

select * from someTable ORDER BY field

If you wish to do it in your data layer you have a number of different
options, probably the easiest would be to have your class implement the
IComparable system interface:

http://msdn2.microsoft.com/en-us/library/4d7sx9hd.aspx

hope that helps!

Sjaakie wrote:

Hi,
I''m, what it turns out to be, fooling around with 3-tier design.
At several websites people get really enthusiastic about using custom
dataobjects instead of datasets/-tables.
While trying to write such layers myself I got stuck on how to get
filtered or sorted data from the data-layer.

This is what I got:

Objects
* class Marble
- MarbleID
- Color
- Size

Data-layer
* SqlHelper - ExecuteNonQuery, ExecuteDataSet, ExecuteReader etc.
* Marbles - int Insert(Marble m), bool Update(Marble m),
Marble[] ListAll, Marble[] Select(int marbleID)

Business-layer
* Marble[] ListMarbles()
* bool UpdateMarble(int marbleID, string color, string size)
etc.

I would like to filter results by using the property-name as column to
filter on. Is this possible? If not... how should I request a filtered
result from the data-layer, without having to create a seperate member
for every possible filter? And is it possible to sort object-properties
in an object-array?

I hope you understand my question....
TIA




If you''re using tsql as your backend database, then check out
http://www.sqlservercentral.com/colu...terproblem.asp

For sorting strong typed objects, check
6/19/2006
Advanced IComparer // Sorting on Multiple Values
at
http://sholliday.spaces.live.com/
I also have a Tiered Example (and 1.1 and 2.0)

You need to look at the SerializeOrder (or something like that) code that
accepts and IDataReader

If you look closely, you ''ll see that you can reuse (and reuse) the
serializer ..........
no matter what/how you created the IDataReader
...

If you''re not using tsql, then you could write a sql generator code .... to
dynamically create sql statements
(like, if you''re using access).
But I''m not a big fan of this.



"Sjaakie" <ke**@secret.itwrote in message
news:45**********************@news.xs4all.nl...

Hi,
I''m, what it turns out to be, fooling around with 3-tier design.
At several websites people get really enthusiastic about using custom
dataobjects instead of datasets/-tables.
While trying to write such layers myself I got stuck on how to get
filtered or sorted data from the data-layer.

This is what I got:

Objects
* class Marble
- MarbleID
- Color
- Size

Data-layer
* SqlHelper - ExecuteNonQuery, ExecuteDataSet, ExecuteReader etc.
* Marbles - int Insert(Marble m), bool Update(Marble m),
Marble[] ListAll, Marble[] Select(int marbleID)

Business-layer
* Marble[] ListMarbles()
* bool UpdateMarble(int marbleID, string color, string size)
etc.

I would like to filter results by using the property-name as column to
filter on. Is this possible? If not... how should I request a filtered
result from the data-layer, without having to create a seperate member
for every possible filter? And is it possible to sort object-properties
in an object-array?

I hope you understand my question....
TIA



I know about the sql-way of dealing with this, but I was looking for
something like implementing the IComparable interface. I''ll dig into it.
Thanks!

Sean Chambers wrote:

If you wish to do this on the data end, you could at an ORDER BY clause
onto your sql statemtent:

select * from someTable ORDER BY field

If you wish to do it in your data layer you have a number of different
options, probably the easiest would be to have your class implement the
IComparable system interface:

http://msdn2.microsoft.com/en-us/library/4d7sx9hd.aspx

hope that helps!

Sjaakie wrote:

>Hi,
I''m, what it turns out to be, fooling around with 3-tier design.
At several websites people get really enthusiastic about using custom
dataobjects instead of datasets/-tables.
While trying to write such layers myself I got stuck on how to get
filtered or sorted data from the data-layer.

This is what I got:

Objects
* class Marble
- MarbleID
- Color
- Size

Data-layer
* SqlHelper - ExecuteNonQuery, ExecuteDataSet, ExecuteReader etc.
* Marbles - int Insert(Marble m), bool Update(Marble m),
Marble[] ListAll, Marble[] Select(int marbleID)

Business-layer
* Marble[] ListMarbles()
* bool UpdateMarble(int marbleID, string color, string size)
etc.

I would like to filter results by using the property-name as column to
filter on. Is this possible? If not... how should I request a filtered
result from the data-layer, without having to create a seperate member
for every possible filter? And is it possible to sort object-properties
in an object-array?

I hope you understand my question....
TIA


这篇关于三层设计;排序和过滤基于对象的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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