分配数据表细胞的一类 [英] Assigning datatable cells to a class

查看:123
本文介绍了分配数据表细胞的一类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎一个奇怪的问题。

This may seem an odd question.

我从来没有使用其他类不是简单的教程等。

I have never used classes other than within simple tutorials etc.

我所试图做的是中采取的是文本数据在一个DataTable,并指定某些细胞或细​​胞群体是一个数据类。

What I am trying to do is to take text data that is in a datatable and assign certain cells or groups of cells to be a data class.

举例来说,假设我有水暖数据我将有一个整体的类,它有东西像零件编号,地点,单位成本,制造商名称等作为零件类型的叫,比方说,部分,然后一个子类为特定的参数,如半径仅适用于弯曲或长度,只适用于管道顶层类。

For example, say I had plumbing data I would have an overall class of part type that had things like part number, location, unit cost, manufacturer's name etc. as a top level class called, say, 'PART' and then a sub-class for specific parameters such as radius which only applies to bends or length which only applies to tubing.

的想法是,被选择的单元的数量,然后将它们标记为包含数据的一类中的属性。

The idea being that a number of cells are selected and then they are marked as containing data for an attribute within a class.

首先,我是在错误的线路;其次,如果这种做法是对的,我怎么会指定一个或多个单元格是一个给定类的?

Firstly, am I on the wrong lines and secondly, if this approach is right how would I designate a cell or cells to be of a given class?

编辑:数据表是从包含格式化数据的用户打开文件中的字符串创建。然后,它会显示在DataGrid中。

Datatable is created from strings in an opened user file containing unformatted data. It is then displayed in a datagrid.

推荐答案

首先重要的是要知道你想用哪种方式和什么样的技术,这是您的上下文越好。

The first important thing is to know which way and what technology you want to use, which is the better for your context.

如果唯一的规定读取数据库中的一些文本的,并将该值的中间数据对象,采取考虑的是:

If the only "requirement" is to read some text from database and put that values to an intermediate data object, the consideration to take is:


  1. 如果唯一的数据访问是关于阅读只是价值观,它不适合采取过工程的解决方案,例如奥姆斯是不是最好的解决方案

  2. 如果它采取一种优雅的方式做是很重要的,也许像佣工一些微小的ORM,也许是好

的考虑可能会更多,现在我将列举一些工具:

The considerations could be more, now I will enumerate some tools:


  1. PetaPoco 为您波苏斯的一个微小的ORM十岁上下的事情,也有细示例和指导

  2. 大规模海量是单文件数据库的有很好的例子,它的完成你想在一个优雅的方式

  3. SqlDataReaderToObject 另一个来完成你想做的事<更快的方法/ li>
  4. 扩展IDbComannd和方法的IDataReader 的最快,无成本的解决方案

  1. PetaPoco "A tiny ORM-ish thing for your POCOs" there are fine examples and instructions
  2. Massive "Massive is a Single File Database" there are very good examples and it's the fastest way to accomplish what you want to do in an elegant way
  3. SqlDataReaderToObject another faster way to accomplish what you want to do
  4. Extension methods for IDbComannd and IDataReader the fastest and costless solutions

根据我的经验,我强烈建议你根据海量的解决方案,没有装配,安装,只是一个代码文件,包括在你的解决方案,但最快的方法,使用datacomnnad和DataReader从4点,可能是一个很好的解决方案。

Based on my experience I strongly suggest you a solution based on Massive, no assembly to install, just a code file to include in you solution, but, the fastest way, using datacomnnad and datareader from the point 4, could be a good solution.

希望这有助于。

这篇关于分配数据表细胞的一类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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