ServiceStack 获取 ORMLite 以使用 T4

ServiceStack get ORMLite to use T4
2021-11-25
  •  译文(汉语)
  •  原文(英语)

我正在为 ORMLite 评估 T4.不管有几个小故障,我都让它工作了.当我在 MSSQL 中将 web.config 指向 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

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

向 OrmLite 项目(或拉取请求)提出问题,以便我们可以跟踪问题.

I am evaluating T4 for ORMLite. Regardless of a couple glitches I made it working. When I point the web.config to Northwind in MSSQL and run that from my SS web project the OrmLite.SP.cs automatically generates the following:

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 ...

They are all from the OrmLite.SP.cs auto-gen code in the OrmLiteSPStatement class...

   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

When I move my mouse over to inspect the error, visual studio says:

Cannot access internal method 'GetFirstColumn' here

How do I fix it?

I am running VS2012, .Net 4.0, ServiceStack 3.9.38.0, SQL2008R2

Solutions1

These T4 templates are still using the deprecated methods that were made internal last week.

Raise an issue with the OrmLite project (or pull-request) so we can keep track of the issue.

转载于:https://stackoverflow.com/questions/15238157/servicestack-get-ormlite-to-use-t4

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入