ServiceStack.OrmLite SqlServer新的Merge方法不适用于不同的引用名称

时间:2015-05-15 05:27:19

标签: c# sql-server servicestack ormlite-servicestack

我尝试在ServiceStack.OrmLite Sql Server中使用新的合并方法,当列的名称与子表相同时,它可以很好地加载引用:

var result = dbCon.SqlList<TimeSheet>("EXEC getAllTimeSheets @timeSheetTypeId, @teamId, @employeeId, @fromDate, @toDate", new { timeSheetTypeId, teamId, employeeId, fromDate, toDate });

// Load the references
var employees = dbCon.Select<Employee>();
var teams = dbCon.Select<Team>();

result.Merge(employees);
result.Merge(teams);

但是正如您在下面看到的那样,ApprovedBy属性有一个子表到Employee表,并且merge方法没有加载“ApprovedBy”的引用如何加载它?

  

员工团队正在被完美加载,但ApprovedBy(也是   员工表)未在我的测试中加载

public class TimeSheet : IHasId<int> 
{
    [Alias("TimeSheetId"), AutoIncrement]
    public int Id { get; set; }

    [Required, References(typeof(Employee))]
    public int EmployeeId { get; set; }
    [Reference]
    public Employee Employee { get; set; }

    public bool? IsApproved { get; set; }

    [References(typeof(Employee))]
    public int? ApprovedById { get; set; }
    [Reference]
    public Employee ApprovedBy { get; set; }

    [References(typeof(Team))]
    public int? TeamId  { get; set; }
    [Reference]
    public Team Team { get; set; }
}

1 个答案:

答案 0 :(得分:1)

现在应该解决这个问题with this commit,可以从现在available on MyGet v4.0.41 + 获得。