how to connect to tables in columns with zero value?
I have the following LINQ query, RMA.fiCharge may be NULL:
Dim query = From charge In Services.dsERP.ERP_Charge _ Join rma In Services.dsRMA.RMA _ On charge.idCharge Equals rma.fiCharge _ Where rma.IMEI = imei Select charge.idCharge
I get a "Convert from type" DBNull "to enter" Integer "is invalid" in query.ToArray() :
Dim filter = _ String.Format(Services.dsERP.ERP_Charge.idChargeColumn.ColumnName & " IN({0})", String.Join(",", query.ToArray))
So, I can add WHERE RMA.fiCharge IS NOT NULL to the request. But how to do it in LINQ or is there another option?
Thanks in advance.
Decision:
The problem was that the DataSet does not support Nullable-Types, but throws an InvalidCastException if you request any NULL values ββfor an integer column (thanks Martinho). The modified LINQ query from dahlbyk works with minor changes. The DataSet generates a boolean property for each column with AllowDbNull = True, in this case IsfiChargeNull .
Dim query = From charge In Services.dsERP.ERP_Charge _ Join rma In (From rma In Services.dsRMA.RMA _ Where Not rma.IsfiChargeNull Select rma) On charge.idCharge Equals rma.fiCharge _ Where rma.IMEI = imei Select charge.idCharge
source share