1

I'm using the code below, but when I call the query, it can only display data of the first row

String query = @"select s.item Type
                 from TypeTable t1
                 outer dbo.Split(t1.Type, ',') s"

dt = SQLCon.getDatatableFromSQL(query);
var _Type = (from rw in dt.AsEnumerable()
             select new TypeAction
                        {
                            Type = rw["Type"].ToString(),
                            // ActiveStatus = Convert.ToBoolean(rw["ActiveStatus"].ToString())
                        }).FirstOrDefault();
return _Type ;

Current:

Type A

Expected:

TypeA
TypeB
TypeC
Ajay2707
  • 5,690
  • 6
  • 40
  • 58
Fate
  • 37
  • 6

1 Answers1

3

Change FirstOrDefault() to ToList().

FirstOrDefault()

Returns the first element of a sequence, or a default value if the sequence contains no elements. Rather than using .ToString() you should use Convert.ToString(<object>) as it will handle null reference exception also. This SO Question can help you much better if you want to display the result in a table.

Suraj Kumar
  • 5,547
  • 8
  • 20
  • 42