Finder 3 different fields from 3 different tables

0

I have 3 tables, Comics (id, Name, number ...), Authors (id, name ...) and Illustrators (id, name ...), what I want to do is a query (for a search engine ) that if I tell him to look for the word "Batman" show me if there are coincidences in the names of both 3 tables.

I have this, that I have been finding for intenert, but it gives me a failure in the Join , and I can not find out why.

Thanks and regards.

PS: Let's see if I explain it well. I try to use the ORM so that when the program does a search with a word I compare it with 3 different fields and if there is a match it returns an object.

  ComictecaEntities mo = new ComictecaEntities();

     String[] titulos = { "hola", "hola", "hola" };

     DbSqlQuery<Comics> nop = mo.Comics.Join(mo.Comics,
        Comics => Comics.Comic_id,
        Autores => Autores.Autor_id,
        Dibujantes => Dibujantes.Dibujante_id,
        (Comics) => new { Comics, Autores, Dibujantes }).Where(fullEntry => fullEntry.Comics.Titulo == "hola");
    
asked by Mario 21.11.2016 в 16:40
source

1 answer

2

From what I see in the tables, they do not have fields to join.

I would do something like this:

var items = from c in Comics
join a in Autores on c.id_autor equals a.id
join d in Dibujantes on c.id_dibujante equals d.id
where a.Nombre.Contains("Batman") || a.Nombre.Contains("Batman") || d.Nombre.Contains("Batman");

I have established that the relationship between comics and authors and between comics and cartoonists is n to 1 if not, we would have to make a relationship table.

I hope it serves you.

    
answered by 22.11.2016 в 16:20