I have a table of animals. The important fields are:
animal_id
mother_animal_id
father_animal_id
mother_animal_id and father_animal_id both relate back to animal.animal_id.
I need to build a result set of an animal and it's ancestors. Each set of immediate ancestors will have a higher level number. I would stop at a maximum of 6 levels above the base animal.
For example, this is what a small dataset might look like:
animal_id, mother_animal_id, father_animal_id, level
104, 98, 97, 0
98, 101, 102, 1
97, 4, 10, 1
101, 60, 44, 2
102, 11, 6, 2
4, 57, 22, 2
10, 66, 21, 2
I'm using SQLite, so I don't have the ability to use a stored procedure. Can I do this with LINQ? If so, how?
TIA
Gary Davis
Open in new window