Nullable Type In Linq C# RRS feed

  • Question

  • in my database there is some row which is null and how can i use nullable type or how can i skip nullable row in linq? but i prefer to use nullable type rather than skip rows
    Wednesday, February 13, 2019 3:34 PM

All replies

  • What type of database eg. SQL-Server?

    What method is used to read data eg. Entity Framework, SqlClient managed provider into a DataTable???

    Perhaps no DataTable but instead using a DataReader

    if (read.Read())
       int colIndex = read.GetOrdinal("MyColumnName");
       maskedTextBox2.Text = read.IsDBNull(colIndex) ? 
                      string.Empty : 

    Using LINQ

    var query1 =
        from c in categories
        where c != null
        join p in products on c.ID equals
        select new { Category = c.Name, Name = p.Name };

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, February 13, 2019 5:27 PM