Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.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# 使用LINQ比较两个字段_C#_Sql Server_Linq_Entity Framework 4.1_Visual Studio Lightswitch - Fatal编程技术网

C# 使用LINQ比较两个字段

C# 使用LINQ比较两个字段,c#,sql-server,linq,entity-framework-4.1,visual-studio-lightswitch,C#,Sql Server,Linq,Entity Framework 4.1,Visual Studio Lightswitch,我正面临一个奇怪的问题。如图所示,实际上我选择了记录编号37,但lightswitch高亮显示为记录编号1。 1 FristName、LastName和HospitalName是表Doctors中的唯一索引,因为每个医生可以有多个地址 2我正在验证此下拉字段,如下所示,以避免用户选择不属于患者所属医院的医生 partial void DoctorsMasterItem_Validate(EntityValidationResultsBuilder results) { i

我正面临一个奇怪的问题。如图所示,实际上我选择了记录编号37,但lightswitch高亮显示为记录编号1。 1 FristName、LastName和HospitalName是表Doctors中的唯一索引,因为每个医生可以有多个地址

2我正在验证此下拉字段,如下所示,以避免用户选择不属于患者所属医院的医生

partial void DoctorsMasterItem_Validate(EntityValidationResultsBuilder results)
    {
        if (this.DoctorsMasterItem != null)
        {


            if (this.HospitalName != this.DoctorsMasterItem.HospitalName)
            {

                results.AddPropertyError("Make Sure the Hospital Patient belongs to and Doctor is also part of that hospital else your letters address would be wrong");

            }

        }

    }
数据模型是


它是否为具有不同医院的任何其他重复名称选择了错误的行?如果是这样,这将清楚地表明,无论采用何种方法进行选择,都没有考虑医院名称。您是否有权访问执行select的代码,或者您是否有办法确保将医院名称考虑在内?如果可以对其进行修改以考虑所有三个条件,则应按预期工作。

更好的方法是过滤下拉框,这样用户就不会看到无效的选择

看看这两篇文章。这就是我认为您应该做的,嵌套或级联组合框:


你的问题是什么?我在这里只看到语句。我遇到的问题是我无法选择正确的记录。例如,尽管我在图像中选择了记录37,但它实际上显示了记录1,验证失败。记录1和37之间的关系是,它们的名字和姓氏相同,但医院名称不同。这不是验证的问题,而是选择列表的问题。请发布代码。我正在使用lightswitch,因此列表选择代码由lightswitch自动生成。你觉得可能是虫子?所以我可以报告它?你用什么代码从Lightswitch获取列表?它选择不同医院的重复名称。不幸的是,我不知道代码的确切位置,正如我之前所说的,我正在使用lightswitch,而且对C或编程来说是相当陌生的。