简体   繁体   English

DataGrid不显示外键值为空的行

[英]DataGrid does not show rows that have null Foreign Key value

I have a WPF DataGrid : 我有一个WPF DataGrid

<DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding SalesInvoiceID}" Header="Sales Invoice ID" Width="100"/>
    <DataGridTextColumn Binding="{Binding CustomerID}" Header="Customer ID" Width="100"/>                  
</DataGrid.Columns>

CustomerID is a foreign key which can be null in database. CustomerID是一个外键,在数据库中可以为null DataGrid Does not show those rows who's CustomerID is null. DataGrid不显示那些CustomerID为null的行。 Please help. 请帮忙。

I want to show all rows including those rows also who's CustomerID field( which is foreign key) is null . 我想显示所有行,包括那些行,以及谁的CustomerID字段(外键)为null。 i used the following query in c# 我在c#使用以下查询

select s.SalesInvoiceID,c.CustomerID from SalesInvoiceID s inner join Customer c on s.CustomerID=c.CustomerID

I want 我想要

SalesInvoiceID  CustomerID
---------------------------
1               23
2               Null
3               24
4               Null   

It is not displaying those rows because you are not giving it those rows 它没有显示这些行,因为您没有给这些行

Test your query in SSMS 在SSMS中测试您的查询

SELECT s.SalesInvoiceID, c.CustomerID 
from SalesInvoiceID s 
inner join Customer c 
   on s.CustomerID = c.CustomerID

Try 尝试

left join Customer c

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM