Results 1 to 1 of 1

Thread: [RESOLVED] Join two tables using Include()

  1. #1

    Thread Starter
    Lively Member FunkySloth's Avatar
    Join Date
    Aug 2016
    Posts
    91

    Resolved [RESOLVED] Join two tables using Include()

    Hi Guys,

    Just a simple one, please help me to combine two tables using include..

    Code:
    Public Class SurveyTemplate()
    {
      Public Guid Id {  get; set; }
      Public string AccountId { get; set; }
      Public string Description { get; set; }
    }
    
    Public Class SurveyHistory()
    {
      public Guid id { get; set; }
      Public Guid SurveyTemplateId { get; set }
      Public SurveyTemplate SurveyTemplates { get; set; }
      Public Guid AccountId { get; set; }
    }
    So this is my repository

    Code:
    Public async Task<List<SurveyHistory>> GetAllSurveyById(Guid accountId)
    {
    Var st = await Context.Set<SurveyHistory>()
    .include(s => st.SurveyTemplates)
    .Where(x => x.AccountId == accountId && x.SurveyTemplates.Id == x.SurveyTemplateId)
    .ToListAsync();
    }
    I tried to other Models with the same Key Id, for example: Note Model with NoteId and Meeting Model with NotedId also, if I use the include, they both return a data, However using this kind of Model with different Id Key its not working, anyone can help me to combine this two table using Include.

    Thank you
    Last edited by FunkySloth; Mar 17th, 2022 at 06:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width