哪种方法在执行另一种方法?

编程入门 行业动态 更新时间:2024-10-15 02:24:11
本文介绍了哪种方法在执行另一种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨... 我有以下两段代码摘录。它基本上是从 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>在消息中写道 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> 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>在留言中写道 新闻: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> 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

更多推荐

哪种方法在执行另一种方法?

本文发布于:2023-11-27 10:43:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637743.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:种方法   哪种   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!