Answer the question
In order to leave comments, you need to log in
How to make a cyclic query to the database?
I can’t make a cyclic query to the database, for example, in Delphi you can do this
var i:int;
......
TQuery1.first;
for i:=0 to Tquery1.RecordCount -1 do // то есть выполняется запрос пока не кончится все записи в таблице
begin
TQuery2.Close;
TQuery2.SQL.Text:='SELECT * FROM tablica WHERE PREDMET='''+TQuery1PREDMET.Value+'''';
Tquery2.ExecSQL;
Tquery1.Next;
end;
There is a table with the names of items Predmets, and there is a table with estimates, dates Balls. the Balls table is linked to Predmets one-to-many (PredmetId). I need to put it out like this
Answer the question
In order to leave comments, you need to log in
Small notes:
1. Before copying the code here, it is better to copy-paste it into a notepad, format it there (delete extra tabs on the left), and then only copy-paste it from the notepad here. It is hard to accept badly formatted code, especially when there is a lot of it.
2. It is very difficult to read code with incomprehensible names. It is better to stick to the tradition of naming in normal English. Fix the page with Google translator in the browser and, if necessary, translate into English - a matter of a couple of seconds. No abbreviations, fields in the models - only the first letter is capitalized. Some of the names I did not understand what you designated them.
3. The teacher of the subject is a user, which means that it is necessary to bind not by his name, but by his Id. Instead of
it is better
4. Then I try to figure out what and how you want to find
What is GR I did not understand. You might think that the entity is a group, but it is a string. Group name? Is each item tied to a specific group?
My choice is how it should be
where Group is an entity that is related to lesson as one-to-many. Sample Model
public class Group
{
public int Id { get; set; }
public string Name { get; set; } // название группы
public ICollection<Lesson> Lessons { get; set; } // предметы
public ICollection<Learner> Learners { get; set; } // ученики
}
var lesson = db.Lessons.Find(l => l.Id == id).Include(t => t.Jjours);
var group = lesson.Group;
var jour = new Journalsliv();
jour.Learners = learners;
jour.Jjoursliv= group.Jjours;
var group = db.Lessons.Find(l => l.Id == id).Include(t => t.Jjours).Group;
var jour = new Journalsliv
{
Learners = db.Learners.Where(k => k.GroupId == group.Id).ToList(),
Jjoursliv = group.Jjours.OrderBy(j => j.Date).ToList() // на всякий случай сортируем по дате
}
@foreach (var roc in Model.Jjoursliv)
{
<tr>
<td>@roc.IIN</td>
@foreach (var roc2 in Model.Jjoursliv)
{
<td>@roc2.OCENKA</td>
}
</tr>
}
@foreach (var learner in learners)
{
<tr>
<td>@learner.First().IIN</td>
@foreach (var jour in learner)
{
<td>@jour.OCENKA</td>
}
</tr>
}
MIT if you don't care how the program is used.
www.freebsdnews.net/wp-content/uploads/open-source...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question