简体   繁体   中英

ServiceStack.OrmLite SqlServer new Merge method doesn't work for different names of references

I tried to use the new merge method in ServiceStack.OrmLite Sql Server it works perfectly to load references when the name of the column is the same as the Child Table:

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);

But as you can see below the ApprovedBy property has a child table to Employee table and the merge method is not loading the references for "ApprovedBy" How can I load it?

Employees and Teams are being loaded perfectly, but ApprovedBy (Also Employees table) is not loading in my tests

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; }
}

现在应该使用此提交解决问题,该提交可从v4.0.41 +版本开始使用 ,现在可以在MyGet上使用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM