Linq To Dataset
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Linq To Dataset

Hybrid View

  1. #1
    Join Date
    Dec 2012

    Linq To Dataset


    i have the Dataset which contains the record from the back end , i need to remove last character of
    the column attribute

    E g: Dataset second column


    out put i need

    Currently i am doing
    var query = Get_X_A_B_C_Obj.AsEnumerable()
    .OrderBy(x => x.Field<string>("Columnname").Substring(0, 4))
    .ThenBy(x => x.Field<string>("Columnname").Substring(5));
    var dt = query.CopyToDataTable<DataRow>();

    but i am not getting

    Can any one please suggest/help me on it ?

  2. #2
    Join Date
    Jul 2012

    Re: Linq To Dataset

    I would think that the best place to do this is in the SQL statement that retreives your DataTable e.g.

    SELECT 1235467X AS 1234567, kumarA AS kumar, CPUD AS CPU

  3. #3
    Join Date
    Feb 2011
    United States

    Re: Linq To Dataset

    Are those the headers associated with your columns? If so, CGKevin has the right idea.

    As written, your query is sorting the data (a) first, using the first four letters of the column name, and then (b) the 5th through last letters of the column name. After executing the lambda expression ( x => ...) in the sort, these values are no longer used. That is, they aren't changing the data, they're just calculating some intermediate value to sort by, which is then forgotten.
    Best Regards,

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)