I created one method in my model :
public IList<Test> GetData(int IDCus){
var list = from j in Context.Test
join y in this.Context.Test1 on j.ID equals y.ID
where j.ID == IDCus
select new {
Tnum = j.Ynum,
Level = y.Level
};
return list.ToList();
}
When I just using select without new, it work normally. But when I tried to used select new in my query, it error : Cannot implicitly convert type System.Collections.Generic.List<AnonymousType#1> to System.Collections.Generic.IList<ITEX.Models.Test>.
Any clues? Thanks.
If both
YnumandLevelare int you first have to verify that the classTestlooks like this:And then the query should look something like this:
If you are using
Testsomewhere else you might have to create a new class for this call, we can call itTest2. Then the class should look like this:And the function for getting the information should look like this:
I hope this will help