已经str是一个字符串格式是
string str = "a='a111' and b='222' and ccc=200";
是样的一个格式,可能条件会更多现在想根据这个字条串条件生成DbParameter应该怎么写啊?
private DbParameter[] fun1(string str)
{
如果传一个str过来(str的格式和上面的差不多,可能条件数量不固定),这里如何转换成DbParameter[]
}
string str = "a='a111' and b='222' and ccc=200";
是样的一个格式,可能条件会更多现在想根据这个字条串条件生成DbParameter应该怎么写啊?
private DbParameter[] fun1(string str)
{
如果传一个str过来(str的格式和上面的差不多,可能条件数量不固定),这里如何转换成DbParameter[]
}
解决方案 »
- 大神求助
- 困扰良久,百度贴吧造成webbrowser假死问题
- winForm界面的事件优先顺序?
- Gridview选中某行,和设定某行某列的一个值的链接?
- how to avoid"Index was outside the bounds of the array"?
- Microsoft Visual Studio 2005 就是Microsoft VS 2005.NET吗?
- 求multipart/form-data提交后台获取数据方法
- 请问 workflow 如何自定义 StateActivity ?
- C# webbrowser控件操作网页中的Iframe
- 关于数据库的选择的小问题。
- 关于软件界面颜色变化的判断问题,跪谢啊!
- 请问什么代码会 引起 消息框的 确认点击 不关闭消息框
var ary = Regex.Matches(str, @"([\w_]+)=([""']?)(.*?)\2(?=\s|$)").OfType<Match>().Select(t => new { field = t.Groups[1].Value, value = t.Groups[3].Value }).ToArray();
{
//string str = "a='a111' and b='222' and ccc=200";
var array = Regex.Matches(str, @"([\w_]+)=([""']?)(.*?)\2(?=\s|$)").OfType<Match>().Select(t => new { field = t.Groups[1].Value, value = t.Groups[3].Value }).ToArray();
if (array.Count() == 0)
return null; DbParameter[] dbParameter = new DbParameter[array.Count()]; for (int i = 0; i < array.Count(); i++)
{
dbParameter[i] = new DbParameter(array[i].field, array[i].value);
}
return dbParameter;
}