You can’t return anonymous types from a method (i.e. select new { ... }
). You need to create a class for that or use Market_Masters
if it is of that type, e.g.:
public IEnumerable<Market_Masters> GetMaster()
{
var x = from n in db.Masters
join chil in db.ChildMasterMasters on n.MasterId equals chil.MasterId into t
select new Market_Masters()
{
MasterId = n.MasterId,
Prod_Name = n.Prod_Name,
Produ_Adress = n.Produ_Adress,
Price = n.Price,
Hello = t
};
return x.ToList();
}
If the type returned is not Market_Masters
you could do something like (replace YourChildType
with your actual type):
public class MarketMastersWithHello : Market_Masters
{
public IEnumerable<YourChildType> Hello { get; set; }
}
and then:
public IEnumerable<MarketMastersWithHello> GetMaster()
{
var x = from n in db.Masters
join chil in db.ChildMasterMasters on n.MasterId equals chil.MasterId into t
select new MarketMastersWithHello()
{
MasterId = n.MasterId,
Prod_Name = n.Prod_Name,
Produ_Adress = n.Produ_Adress,
Price = n.Price,
Hello = t
};
return x.ToList();
}
1
solved Which type should I return?