日期:2014-05-18  浏览次数:20404 次

asp.net通用查询
asp.net通用查询,各位有没有好的模块,可否发给我一个看看,谢谢了,没有分。
最好可以选择表中的列,进行组合查询。

------解决方案--------------------
选择表中的列??根据多个字段查询么?三层不会就没办法了- -
C# code

/// <summary>
        /// 根据日期,资源名称,资源描述查询资源信息
        /// </summary>
        /// <returns></returns>
        public DataSet FN_SerchByDateAndType(Guid FolderId, NRModel.File model, string createdate, string endate)
        {
            string strSql = "select * from t_File where 1 =1 and FolderId=@FolderId";
            string strWhere = "";
            if (!string.IsNullOrEmpty(model.FileNam))
            {
                strWhere += " and FileNam like @FileNam";
            }
            //if (!string.IsNullOrEmpty(model.Decription)k)
            //{
            //    strWhere += " and Decription like @Decription";
            //}
            if (!string.IsNullOrEmpty(createdate) || !string.IsNullOrEmpty(endate))
            {
                strWhere += " and CreateOn between @createdate and @endate order by ModefyOn desc";
            }
            strSql += strWhere;
            SqlParameter[] parameters = {
                                new SqlParameter("@FolderId", SqlDbType.UniqueIdentifier),
                                new SqlParameter("@FileNam", SqlDbType.NVarChar, 256),
                                new SqlParameter("@createdate", SqlDbType.NVarChar),
                                new SqlParameter("@endate", SqlDbType.NVarChar)
                        };
            parameters[0].Value = FolderId;
            parameters[1].Value = "%" + model.FileNam + "%";
            //parameters[1].Value = "%" + model.Decription + "%";
            parameters[2].Value = createdate;
            parameters[3].Value = endate;
            return DbHelperSQL.Query(strSql, parameters);
            //SqlParameter[] parameters = new SqlParameter[4];
            //parameters[0] = new SqlParameter("@FileNam", model.FileNam);
            //parameters[1] = new SqlParameter("@stardate", createdate);
            //parameters[2] = new SqlParameter("@enddate", endate);
            ////执行存储过程
            //return DbHelperSQL.RunProcedure("P_UserSerch", parameters, "t_File");
        }