Answers for "Entity Framework double join"

C#
0

Entity Framework double join

public class SomeContext: DbContext
    {
        public SometContext(DbContextOptions<SomeContext> options) : base(options) { }

        public DbSet<SomeJoinTable> Relationships { get; set; }
        public DbSet<Author> Authors { get; set; }
        public DbSet<Books> Books { get; set; }


        public string GetTemplateMethods(string models)
        {
            var result = (from _relationships in Relationships
                join _books in Books on <left-hand comparator> equals <right-hand comparator>
                join _authors in Authors on _relationships.AuthorId equals _books.AuthorId

                select new
                {
                    AuthorName = _authors.MethodName,
                    AuthorId = _authors.AuthorId,
                    BookId = _books.BookId
                }).ToList();
            
            return JsonConvert.SerializeObject(result);
        }
    }
Posted by: Guest on January-15-2021

Code answers related to "Entity Framework double join"

C# Answers by Framework

Browse Popular Code Answers by Language