I work on asp.net core .I face issue i can't use List dirctly without convert to datatable
so How to use this code based on list without convert to datatable
var BranchesList = _OsuBranch.GetList(x => x.BRTYPE =="BR" && x.OSU_Is_Active == "Y");
DataTable dsBranchs = ConvertListToDataTable(BranchesList);
if (dsBranchs.Rows.Count > 0)
{
foreach (DataRow br in dsBranchs.Rows)
{
strBranch = _OsuBranch.GetFirst(x => x.brcode == Convert.ToString(br["brcode"])).brcode.ToString(); //Convert.ToString(br["brcode"]).Trim();
AppID = _OsuBranch.GetFirst(x => x.brcode == strBranch).AppID.ToString();
}
}
public virtual List GetList(Expression> where)
{
return dbSet.Where(where).ToList();
}
public partial class OsuBranch
{
[Key]
public string brcode { get; set; }
public string AppID { get; set; }
public string jbrcode { get; set; }
public string BRTYPE { get; set; }
public string JSubUnit { get; set; }
public string DeptNo { get; set; }
public string OSU_Is_Active { get; set; }
}
so How to use dirct list BranchesList and loop within it and assign strBranch and AppId
Amit MohantyPosted Jul 19, 2023, 5:36 AM
Naimish MakwanaPosted Jul 19, 2023, 3:57 AM
To use the
BranchesListdirectly without converting it to aDataTable, you can modify your code as follows:Thanks