ServiceStack让ORMLite使用T4

时间:2013-03-06 02:58:42

标签: c# servicestack ormlite-servicestack

我正在为ORMLite评估T4。无论发生什么故障,我都让它发挥作用。当我将web.config指向MSSQL中的Northwind并从我的SS Web项目运行时,OrmLite.SP.cs会自动生成以下内容:

public class OrmLiteSPStatement
{
 ....
        try
        {
            reader = command.ExecuteReader();
#pragma warning disable 618
            return reader.GetFirstColumn<T>();
#pragma warning restore 618
        }
        finally ...

        try
        {
            reader = command.ExecuteReader();
#pragma warning disable 618
            return reader.GetScalar<T>();
#pragma warning restore 618
        }
        finally ...

        try
        {
            reader = command.ExecuteReader();
#pragma warning disable 618
            return reader.GetFirstColumn<T>();
#pragma warning restore 618
        }
        finally ...

        try
        {
            reader = command.ExecuteReader();
#pragma warning disable 618
            return reader.GetFirstColumnDistinct<T>();
#pragma warning restore 618
        }
        finally ...

它们全部来自OrmLiteSPStatement类中的OrmLite.SP.cs自动生成代码......

   Error    1   No overload for method 'GetFirstColumn' takes 0 arguments 
   Error    2   No overload for method 'GetScalar' takes 0 arguments 
   Error    3   No overload for method 'GetFirstColumn' takes 0 arguments 
   Error    4   No overload for method 'GetFirstColumnDistinct' takes 0 arguments

当我移动鼠标检查错误时,visual studio说:

Cannot access internal method 'GetFirstColumn' here

我该如何解决?

我正在运行VS2012,.Net 4.0,ServiceStack 3.9.38.0,SQL2008R2

1 个答案:

答案 0 :(得分:1)

这些T4模板仍在使用上周内部弃用的方法。

Raise an issue with the OrmLite project(或拉取请求),以便我们可以跟踪问题。