I don't know whether it is a bug or not

Jul 21, 2009 at 3:10 AM

SqlStatement sql = new SqlStatement(
                "SELECT SUM(zl) AS number, lh as title, 0 as percent1 FROM vv_rkcx WHERE zfbz=@zfbz GROUP BY lh",
                new DataParameter("@zfbz", false)
                );

            var l_dqkc = DbEntry.Context.ExecuteList<vtb_obj>(sql).OrderBy(p => p.title).ToArray();

 public class vtb_obj : IDbObject
    {
        public double percent1 { get; set; }

        public double number { get; set; }

        public string title { get; set; }

    }

这个0 as percent1无论如何也映射不到percent1上,改成0.00也不行。貌似0 as percent1只有double映射不了,int可以,string也可以,后来我就用string了

Coordinator
Jul 21, 2009 at 4:29 AM

这个应该是数据库的问题了,因为数据库中没有这个项,所以数据库驱动就返回它猜测的类型,DbEntry一般不对返回类型做转换处理。

当然,不同的数据库处理不太一样,比如 Oracle,几乎所有类型都需要做类型转换........