0
luqc1985 created
public class Form : FullAuditedEntity
{
}
[Table("Flows")]
public class FlowUnit : FullAuditedEntity
{
public virtual long FormId { get; set; }
[ForeignKey("FormId")]
public virtual FormUnit FlowForm { get; set; }
}
I have such two tables, there is a primary foreign key relationship, after the data is migrated, when using Repository.GetAsync query, flowUnit.FlowForm is null, I am using EntityFrameworkCore.SqlServer, the previous EntityFramework version does not seem to Question, how can I make the flowUnit.FlowForm have a corresponding value? Can anyone help me for this ? <span class="colour" style="color: rgb(0, 0, 0);">Thanks in advance for any advice given.</span>
4 Answer(s)
-
1
var flowUnit = await flowUnitRepository.GetAll() .Include(fu => fu.FlowForm) .FirstAsync(fu => fu.Id == input.Id.Value);
-
0
public class Form : FullAuditedEntity { public virtual List<FlowUnit> FlowUnitList { get; set; } }
If I add a navigation property to the Form, FlowUnitList, how should the query be written to get the list?
-
0
var flowUnit = await flowUnitRepository.GetAll() .Include(fu => fu.FlowForm) .ThenInclude(ff => ff.FlowUnitList) .FirstAsync(fu => fu.Id == input.Id.Value);
-
0
Thank you, I already understand the logic inside.