想飞的鱼丶 2016-08-11 03:14 采纳率: 0%
浏览 738

能不能解释下什么意思啊

public static string GetWhereCondition(T t)
{
//构造查询条件
StringBuilder where = new StringBuilder(512);
Type type = typeof(T);
if (t == null)
return string.Empty;
PropertyInfo sortproperty = null;
string defaultorderby = string.Empty;
foreach (PropertyInfo item in type.GetProperties())
{
if (string.IsNullOrEmpty(defaultorderby))
{
defaultorderby = item.Name;
}
//字段为空不拼接入查询条件
if (item.GetValue(t, null) == null)
continue;

  • 写回答

2条回答 默认 最新

  • wolf犭良 2016-08-11 04:29
    关注

    代码没有帖完吧,从名字上看是该方法的功能是,拼接SQL查询语句WHERE部分。
    根据反射取出对象t中的属性拼接出查询条件,并设置默认排序方式,

    评论

报告相同问题?