Exemplo n.º 1
0
    public static DataTable FilterDT(DataTable dt, DataTable dsAccess, string CompareField1, string CompareField2, string TextShow)
    {
        DataTable dtResult = new DataTable();

        if (dt != null && dt.Rows.Count > 0)
        {
            var result = from dataRows1 in dt.AsEnumerable()
                         join dataRows2 in dsAccess.AsEnumerable()
                         on dataRows1.Field <int>(CompareField1) equals dataRows2.Field <int>(CompareField2)
                         select new { CompareField1 = dataRows1[CompareField1], TextShow = dataRows1[TextShow] };

            dtResult = AllClasses.LINQResultToDataTable(result);
        }
        dtResult.Columns["CompareField1"].ColumnName = CompareField1;
        dtResult.Columns["TextShow"].ColumnName      = TextShow;
        return(dtResult);
    }