哪种方法在执行另一种方法? [英] which approach is out performing the other ?

查看:59
本文介绍了哪种方法在执行另一种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...


我有以下两段代码摘录。它基本上是从
dataReader读取数据并将它添加到一个集合中......


摘录A:

*******


使用ProjectData

而.Read

Me.Add(DirectCast (.Item(" project_id"),Guid),_

DirectCast(.Item(" start_date"),DateTime),_

DirectCast(.Item( " end_date"),DateTime),_

DirectCast(.Item(" priority"),Integer),_

DirectCast(.Item(" description" ),String),_

DirectCast(.Item(" project_manager"),String)

结束时

结束

摘录B:

********

Hi...

I have the following two code excerpts. It basically reads data froma
dataReader and adds it
to a collection....

Excerpt A:
*******

With ProjectData
While .Read
Me.Add(DirectCast(.Item("project_id"), Guid), _
DirectCast(.Item("start_date"), DateTime), _
DirectCast(.Item("end_date"), DateTime), _
DirectCast(.Item("priority"), Integer), _
DirectCast(.Item("description"), String), _
DirectCast(.Item("project_manager"), String)
End While
End With
Excerpt B:
********

推荐答案

你没有发布任何与B比较的东西。一般情况下,你想使用

索引。


Me.Add(.Item(" project_id")) )


改为使用Me.Add(Item(0))


你可以使用DataReader.GetOrdingal While循环的一侧将允许

你使用一个可读的名称但仍然使用索引....如果你使用字符串

列名,他们需要一遍又一遍地解决。


Bill Vaughn建议使用枚举,甚至可以减少

GetOrdinal的开销。

" ;铁皮" < DW **** @ yahoo.com>在消息中写道

news:Ob ************** @ tk2msftngp13.phx.gbl ...
YOu didn''t post anything with B to compare to. In general, you want to use
indexes though.

Me.Add(.Item("project_id"))

instead use Me.Add(Item(0))

You can use DataReader.GetOrdingal outside of the While loop which will let
you use a readable name but still use the indexes....if you use strings for
the columnames, they need to be resolved over and over again.

Bill Vaughn recommends using an enum which even cuts out the overhead of
GetOrdinal.
"tinman" <dw****@yahoo.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
嗨...

我有以下两个代码摘录。它基本上从dataReader读取数据并将其添加到一个集合中....

摘录A:
*******

使用ProjectData
而.Read
Me.Add(DirectCast(.Item(" project_id"),Guid),_
DirectCast(.Item(" start_date") ,DateTime),_
DirectCast(.Item(" end_date"),DateTime),_
DirectCast(.Item(" priority"),Integer),_
DirectCast(。 Item(description),String),_
DirectCast(.Item(" project_manager"),String)
结束时
结束

摘录B:
********
Hi...

I have the following two code excerpts. It basically reads data froma
dataReader and adds it
to a collection....

Excerpt A:
*******

With ProjectData
While .Read
Me.Add(DirectCast(.Item("project_id"), Guid), _
DirectCast(.Item("start_date"), DateTime), _
DirectCast(.Item("end_date"), DateTime), _
DirectCast(.Item("priority"), Integer), _
DirectCast(.Item("description"), String), _
DirectCast(.Item("project_manager"), String)
End While
End With
Excerpt B:
********



Tinman,

除了William的评论。


使用DataReader.Get * Type *方法比使用DirectCast更容易。

Get * Type *方法需要顺序,你可以在循环之前使用GetOrdinal,或者如果你知道返回的特定字段就定义一个枚举。


类似的东西:


Enum Field

project_id

start_date

end_date

priority

描述

project_manager

结束枚举
Tinman,
In addition to William''s comments.

Using the DataReader.Get*Type* methods are easier then using DirectCast. The
Get*Type* methods require the ordinal, you can use either GetOrdinal before
the loop, or define an Enum if you know the specific fields returned.

Something like:

Enum Field
project_id
start_date
end_date
priority
description
project_manager
End Enum
Me.Add(.GetGuid(Field.project_id)), _
.GetDateTime(Field.start_date)),_
。GetDateTime(Field.end_date)),_
。GetInt32(Field.priority)),_
.GetString( Field.description)),_
.GetString(Field.project_manager))


David Sceppa的书Microsoft ADO.NET - Core Reference来自MS Press的

一旦你了解ADO.NET,就可以获得优秀的ADO.NET教程和优秀的桌面参考。


希望这有帮助

Jay


" tinman" < DW **** @ yahoo.com>在留言中写道

新闻:Ob **************** @ tk2msftngp13.phx.gbl ...嗨...
我有以下两个代码摘录。它基本上从dataReader读取数据并将其添加到一个集合中....

摘录A:
*******

使用ProjectData
而.Read
Me.Add(DirectCast(.Item(" project_id"),Guid),_
DirectCast(.Item(" start_date") ,DateTime),_
DirectCast(.Item(" end_date"),DateTime),_
DirectCast(.Item(" priority"),Integer),_
DirectCast(。 Item(description),String),_
DirectCast(.Item(" project_manager"),String)
结束时
结束

摘录B:
********
Me.Add(.GetGuid(Field.project_id)), _
.GetDateTime(Field.start_date)), _
.GetDateTime(Field.end_date)), _
.GetInt32(Field.priority)), _
.GetString(Field.description)), _
.GetString(Field.project_manager))
David Sceppa''s book "Microsoft ADO.NET - Core Reference" from MS Press is
both a good Tutorial on ADO.NET plus an excellent desk reference once you
know ADO.NET.

Hope this helps
Jay

"tinman" <dw****@yahoo.com> wrote in message
news:Ob****************@tk2msftngp13.phx.gbl... Hi...

I have the following two code excerpts. It basically reads data froma
dataReader and adds it
to a collection....

Excerpt A:
*******

With ProjectData
While .Read
Me.Add(DirectCast(.Item("project_id"), Guid), _
DirectCast(.Item("start_date"), DateTime), _
DirectCast(.Item("end_date"), DateTime), _
DirectCast(.Item("priority"), Integer), _
DirectCast(.Item("description"), String), _
DirectCast(.Item("project_manager"), String)
End While
End With
Excerpt B:
********



比尔,
你没有用B发布任何东西来比较。一般来说,你想要
使用索引。

Me.Add(.Item(" project_i) d)

改为使用Me.Add(Item(0))

你可以在While循环之外使用DataReader.GetOrdingal,这将是
让你使用可读的名称但仍然使用索引....如果你使用字符串
作为列名,他们需要一遍又一遍地解决
YOu didn''t post anything with B to compare to. In general, you want to use indexes though.

Me.Add(.Item("project_id"))

instead use Me.Add(Item(0))

You can use DataReader.GetOrdingal outside of the While loop which will let you use a readable name but still use the indexes....if you use strings for the columnames, they need to be resolved over and over again




我恭敬地不同意。


当这成为问题时你应该直接停止使用OOP。


它与OOP无关,但是,通过写入直接命令,OOP也会产生少量的b
。内存和处理器区域的开销是直接的,而且来自一个ammount,这可能比一个长的鼠标中风要少100亿英镑的时间。


只是我的意见。


cor



I respectfully do not agree.

When this becomes an issue you should direct stop using OOP.

It has nothing to do with OOP, however OOP gives also a small amount of
overhead comparing that by writting direct commands. The overhead is direct
in the memory and processor area, and from an ammount, which is probably
1000000000000000000000000 times less than one long mouse stroke.

Just my opinion.

cor


这篇关于哪种方法在执行另一种方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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