Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 林克。要求了解C语言中的多个“选择与从”和“位置”_C#_Linq_Select - Fatal编程技术网

C# 林克。要求了解C语言中的多个“选择与从”和“位置”

C# 林克。要求了解C语言中的多个“选择与从”和“位置”,c#,linq,select,C#,Linq,Select,我是LINQ的新手,在阅读一些代码时遇到了麻烦。我不想找人向我解释代码,而是想知道: 首先,我需要了解哪些合适的搜索词。例如,当您有多个Select语句时,您将其称为什么。我的直觉是这是一个内部连接,但我不熟悉LINQ语法 第二,能给我指一些参考资料吗?我已经试过了,但我认为我无法找到合适的搜索词限制了我。我要么提出简单的fromselect语句,要么提出内部连接语句 代码: 这个查询非常难看,所以我为您分析了它。希望您能够更轻松地解析: // Find the nations whose na

我是LINQ的新手,在阅读一些代码时遇到了麻烦。我不想找人向我解释代码,而是想知道:

首先,我需要了解哪些合适的搜索词。例如,当您有多个Select语句时,您将其称为什么。我的直觉是这是一个内部连接,但我不熟悉LINQ语法

第二,能给我指一些参考资料吗?我已经试过了,但我认为我无法找到合适的搜索词限制了我。我要么提出简单的fromselect语句,要么提出内部连接语句

代码:


这个查询非常难看,所以我为您分析了它。希望您能够更轻松地解析:

// Find the nations whose name matches nationReportAbbr
// Find the nations whose name matches nationReportAbbr
var matchingNations = _database.SessionDatabaseObject.Nations.Where(nation =>
    String.Equals(nation.ReportAbbreviation, nationReportAbbr, StringComparison.CurrentCultureIgnoreCase));
if (matchingNations.Any())
{
    Nation matchingNation = matchingNations.First();

    // Find the sexes whose name matches sexReportAbbr
    var matchingSexes = _database.SessionDatabaseObject.Sexes.Where(sex =>
        String.Equals(sex.Name, sexReportAbbr, StringComparison.CurrentCultureIgnoreCase));
    if (matchingSexes.Any())
    {
        Sex matchingSex = matchingSexes.First();

        // Find the recording sites with the appropriate nation and sex
        var matchingRecordingSites = _database.SessionDatabaseObject.RecordingSites.Where(recordingSite =>
            recordingSite.NationId == matchingNation.Id && recordingSite.SexId == matchingSex.Id);
        if (matchingRecordingSites.Any())
        {
            RecordingSite matchingRecordingSite = matchingRecordingSites.First();

            // Find the interviewers with the appropriate recording site
            var matchingInterviewers = _database.SessionDatabaseObject.Interviewers.Where(interviewer =>
                interviewer.RecordingSiteId == matchingRecordingSite.Id);
            if (matchingInterviewers.Any())
            {
                Interviewer matchingInterviewer = matchingInterviewers.First();

                // Find the readings taken by the appropriate interviewer whose RunEventId matches the provided _entry.Id
                var matchingReadings = _database.SessionDatabaseObject.Readings.Where(reading =>
                    reading.InterviewerId == matchingInterviewer.Id
                    && reading.RunEventId == _entry.Id);
                if (matchingReadings.Any())
                {
                    Reading matchingReading = matchingReadings.First();

                    // Find the height
                    float? height = matchingReading.Height;
                    if (height.HasValue)
                    {
                        return ((int)Math.Floor(height.Value)).ToString();
                    }
                }
            }
        }
    }
}

return String.Empty;

这个查询非常难看,所以我为您分析了它。希望您能够更轻松地解析:

// Find the nations whose name matches nationReportAbbr
// Find the nations whose name matches nationReportAbbr
var matchingNations = _database.SessionDatabaseObject.Nations.Where(nation =>
    String.Equals(nation.ReportAbbreviation, nationReportAbbr, StringComparison.CurrentCultureIgnoreCase));
if (matchingNations.Any())
{
    Nation matchingNation = matchingNations.First();

    // Find the sexes whose name matches sexReportAbbr
    var matchingSexes = _database.SessionDatabaseObject.Sexes.Where(sex =>
        String.Equals(sex.Name, sexReportAbbr, StringComparison.CurrentCultureIgnoreCase));
    if (matchingSexes.Any())
    {
        Sex matchingSex = matchingSexes.First();

        // Find the recording sites with the appropriate nation and sex
        var matchingRecordingSites = _database.SessionDatabaseObject.RecordingSites.Where(recordingSite =>
            recordingSite.NationId == matchingNation.Id && recordingSite.SexId == matchingSex.Id);
        if (matchingRecordingSites.Any())
        {
            RecordingSite matchingRecordingSite = matchingRecordingSites.First();

            // Find the interviewers with the appropriate recording site
            var matchingInterviewers = _database.SessionDatabaseObject.Interviewers.Where(interviewer =>
                interviewer.RecordingSiteId == matchingRecordingSite.Id);
            if (matchingInterviewers.Any())
            {
                Interviewer matchingInterviewer = matchingInterviewers.First();

                // Find the readings taken by the appropriate interviewer whose RunEventId matches the provided _entry.Id
                var matchingReadings = _database.SessionDatabaseObject.Readings.Where(reading =>
                    reading.InterviewerId == matchingInterviewer.Id
                    && reading.RunEventId == _entry.Id);
                if (matchingReadings.Any())
                {
                    Reading matchingReading = matchingReadings.First();

                    // Find the height
                    float? height = matchingReading.Height;
                    if (height.HasValue)
                    {
                        return ((int)Math.Floor(height.Value)).ToString();
                    }
                }
            }
        }
    }
}

return String.Empty;

这些是嵌套查询。您可以在这里找到信息:这对您来说应该是一个好的开始,查询似乎是由不知道Linq连接的人完成的。我喜欢所有这些第一次调用。派对上的乐趣。@Ryk-你讨厌Linq,因为有人会写一行糟糕的Linq行?相信我,他的查询看起来也一样难看。这些是嵌套查询。您可以在这里找到信息:这对您来说应该是一个好的开始,查询似乎是由不知道Linq连接的人完成的。我喜欢所有这些第一次调用。派对上的乐趣。@Ryk-你讨厌Linq,因为有人会写一行糟糕的Linq行?相信我,他的问题看起来也一样难看。