hi All ,
I am trying to defining user defined column in linq for , the below bolder code its returning , i want to define new column StateNameCode its user definesd like alias name sqlserver, getting error
public DataTable GetStates(int StateiD)
{
var dtStates = new DataTable();
try
{
using (var db = new Mydatabaseentitites())
{
var drstates = (from pl in db.Places
join st in db.States on pl.StateID equals st.StateId
join c in db.country on st.CountryId equals c.CountryId
where (st.StateId == StateiD)
select new
{
o.StateID,
o.StateName,
StateNameCode = o.StateName + '{' + o.StateID+ '}'
}
).Distinct().GetDataTable();
if (drstates.Rows.Count > 0)
{
dtStates = drstates;
return dtStates;
}
return dtStates;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}