How to differentiate between two similar fields in Linq Join tables

Posted by Azhar on Stack Overflow See other posts from Stack Overflow or by Azhar
Published on 2010-06-14T13:28:42Z Indexed on 2010/06/14 16:42 UTC
Read the original article Hit count: 347

How to differentiate between two select new fields e.g. Description

c.Description and lt.Description

    DataTable lDt = new DataTable();
    try
    {

        lDt.Columns.Add(new DataColumn("AreaTypeID", typeof(Int32)));
        lDt.Columns.Add(new DataColumn("CategoryRef", typeof(Int32)));
        lDt.Columns.Add(new DataColumn("Description", typeof(String)));
        lDt.Columns.Add(new DataColumn("CatDescription", typeof(String)));

        EzEagleDBDataContext lDc = new EzEagleDBDataContext();
        var lAreaType = (from lt in lDc.tbl_AreaTypes
                            join c in lDc.tbl_AreaCategories on lt.CategoryRef equals c.CategoryID
                            where lt.AreaTypeID== pTypeId
                            select new { lt.AreaTypeID, lt.Description, lt.CategoryRef, c.Description }).ToArray();

        for (int j = 0; j< lAreaType.Count; j++)
        {
            DataRow dr = lDt.NewRow();
            dr["AreaTypeID"] = lAreaType[j].LandmarkTypeID;
            dr["CategoryRef"] = lAreaType[j].CategoryRef;
            dr["Description"] = lAreaType[j].Description;
            dr["CatDescription"] = lAreaType[j].;
            lDt.Rows.Add(dr);
        }
    }
    catch (Exception ex)
    {
    }

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about LINQ