【问题标题】:OrmLite: executing stored procedure and mapping the result onto model does not work when attributes are usedOrmLite:使用属性时执行存储过程并将结果映射到模型上不起作用
【发布时间】:2013-04-12 20:49:56
【问题描述】:

ORMLite 将存储过程调用的结果投影到模型上的实际要求是什么。我有一个具有某些属性的类,它不会正确映射 sp 的输出。如果我删除属性,那么它会正确映射它。例如:

public class Test
{
   [Alias("InsuredId")]
   public string Id { get; set; }
   public string LastName { get; set; }
   public string FirstName { get; set; }
   public string MiddleInitial { get; set; }
}

SP 返回以下列:InsuredId、LastName、FirstName、MiddleInitial 等。 如果我有 Alias 属性,则所有属性都填充为 null。如果我删除属性,那么除了 ID 之外一切都很好。以下是实际代码。

var  test =
        db.SqlList<Test>(
            "EXEC up_InsuredSearchTest @ItemId, @FirstName, @LastName, @DateOfBirth, @Max_Search_Records",
            new
                {
                    ItemId = memberId,
                    FirstName = firstName,
                    LastName = lastName,
                    DateOfBirth = dateOfBirth.HasValue? dateOfBirth.Value.ToShortDateString() : "",
                    Max_Search_Records = MAX_SEARCH_RECORDS
            });

【问题讨论】:

    标签: servicestack ormlite-servicestack


    【解决方案1】:

    ServiceStack 并不是真正的问题。返回的值是一个 int 但被映射为字符串,它在 ServiceStack 中默默地失败,但记录了错误。错误信息不是很丰富,所以我不得不通过 ORMLite 源进行调试以找出问题所在。

    【讨论】:

      猜你喜欢
      • 2014-07-01
      • 2020-12-17
      • 2016-08-24
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多