Hi @王好 王, Welcome to Microsoft Q&A.
This code looks fine.
public object SelectGroupLabelList()
{
using (var information_context = new InformationContext())
{
var query = from hlabel in information_context.Hlabels
join nlabel in information_context.Nlabels
on hlabel.Hid equals nlabel.Nhid
select new {
hlabel,
nlabel
};
return query.ToList();
}
}
This code returns a list of anonymous type objects, each containing hlabel and nlabel. This anonymous type object is created by the select new { hlabel, nlabel } portion of the LINQ query. In this anonymous type object, each hlabel corresponds to an Hlabel object, and each nlabel corresponds to an Nlabel object.
You use query.ToList() to convert the query results into a list and ultimately return the list. This way, your SelectGroupLabelList method will return a list containing objects of anonymous type.
Best Regards,
Wenbin
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.