locked
LINQ CopyToDataTable not displaying RRS feed

  • Question

  • 821 Points

    949 Posts

    LINQ CopyToDataTable not displaying

    17 minutes ago|LINK

    hi all,

    im using LINQ to DataSet.

     var Result = from dataset in objDataSet.Tables[0].AsEnumerable()
                                     where dataset.Field<string>("CO1") == "T" && dataset.Field<string>("CO2").StartsWith("Z")
                                     select dataset;
     if (Result.AsDataView().Count > 0)
                    {
                        dtOutput = Result.CopyToDataTable();
                        dsOutput.Tables.Add(dtOutput);
                    }above code is perfect, another place i have slightly changed the code, like below

     var Result = (from dataset in objDataSet.Tables[0].AsEnumerable()
                                     where dataset.Field<string>("CO1") == "T" && dataset.Field<string>("CO2").StartsWith("Z")
      select new { CO1 = dataset.Field<string>("CO1") }).Distinct(); 

    if (Result.AsDataView().Count > 0)
                    {
                        dtOutput = Result.CopyToDataTable();
                        dsOutput.Tables.Add(dtOutput);
                    }

    after specified the columns in select cluase, the AsDataView(),CopyToDataTable() method's not displaying when i press DOT symbol,why it is not displaying? how to resolve this?


    Thanks In Advance, Jeyaseelan

    Monday, October 8, 2012 5:02 AM

Answers

All replies