Select column based on value in another column RRS feed

  • Question

  • Having trouble trying to select a column based on another columns value. Keep getting an error An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll

    What I am trying to do is set quantity = the value which is not null so if userQuantity is null then take customerQuantity ect.

    ID | UploadSite | UserQuantity |CustomerQuantity
    1  |  0         |  1        | NULL
    2  |  1         | NULL      |  2

      Stocks = (From p In constocks
                             Where p.UploadSite.Equals(ListSite.Text)
                             Select New StocksModel With {.iD = p.RecordID, .productID = p.ProductID, .factoryID = p.FactoryID, .[date] = p.Date,
                                  .quantity = If(Not IsDBNull(p.UserQuantity), p.UserQuantity, If(Not IsDBNull(p.CustomerQuantity), p.CustomerQuantity, p.UserQuantity)),
                .classification = p.Classification, .CustomerQuantity = p.CustomerQuantity}).ToList()

    Can anyone see what I am doing wrong?


    Wednesday, March 8, 2017 12:19 PM

All replies