मैं लेनदेन डेटा को पॉप्युलेट करने की कोशिश कर रहा हूं जहां खाता संख्या मौजूद नहीं है। मुझे यह प्राप्त करने के लिए खाता तालिका तक पहुंचने की आवश्यकता है। मैं निम्न त्रुटि जहाँ मैंअंतर्निहित रूप से प्रकार 'System.Collections.Generic.IEnumerable <AnonymousType # 1>' to 'System.Collections.Generic.List <modelClass>
परोक्ष System.Collections.Generic.List<ProjectModel.Transaction>
त्रुटि के प्रकार System.Collections.Generic.IEnumerable<AnonymousType#1>
कनवर्ट नहीं कर सकता IEnumerable वापस जाने के लिए कोशिश कर रहा हूँ हो रही है .ToList() के शीर्ष पर दिखाया गया है, कोड के भाग। मैं क्या गलत कर रहा हूं?
कोड है:
public static IEnumerable<Transaction>GetAllTransactions()
{
List<Transaction> allTransactions = new List<Transaction>();
using (var context = new CostReportEntities())
{
allTransactions = (from t in context.Transactions
join acc in context.Accounts on t.AccountID equals acc.AccountID
where t.AccountID == acc.AccountID
select new
{
acc.AccountNumber,
t.LocalAmount
}).ToList();
}
return allTransactions;
}
यह पूरी तरह से काम किया। उत्कृष्ट जवाब मुझे सही दिशा में डालने के लिए बहुत बहुत धन्यवाद। इसे करने से मैंने कुछ अन्य चीजें भी सीखी हैं। अब मुझे पता है कि व्यूमोडेल क्या है। – shaz