动态成员c#

扫码查看
本文介绍了动态成员c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个类,它允许我将数据插入到我传入该类的任何mysql表中。在大多数情况下,除了向sql查询添加参数外,我已经完成了所有工作。


我所做的是将列名/列类型的ArrayList传递给我的方法,然后我获取此数据并解析出来并从那里构建我的查询。我遇到的一个问题是,当向查询添加参数时,我无法弄清楚如何获取传入的数据并将其与MySqlDbType结合使用。


这是一个简短的片段

cmd.Parameters.Add(fldName,MySqlDbType.VarChar); //静态添加方式


这是我目前的代码库。就像一个简短的fyi,数组列表是一个多维的arraylist。我知道下面的代码是错误的,现在确定如何使用字符串fldType作为MySqlDbType的成员。

展开 | 选择 | 换行 | 行号

解决方案



I am working on a class that will allow me to insert data into any mysql table that I pass into the class. For the most part I have everything done except for adding parameters to the sql query.

What I have done is pass an ArrayList of column names/ column types into my method, and then I take this data and parse it out and build my query from there. The one issue I have is, when adding parameters to the query, I am unable to figure out how to take the data I passed in and use it in conjunction with MySqlDbType.

Here is a short snippet
cmd.Parameters.Add(fldName, MySqlDbType.VarChar); // static way to add

Here is my current code base. Just as a short fyi, the array list is a multidimensional arraylist. I know the code below is wrong, just now sure how to use the string fldType as a member of MySqlDbType.

Expand|Select|Wrap|Line Numbers

解决方案




这篇关于动态成员c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 16:02
查看更多