2009-05-14 2 views

답변

0

하면 다음 LinqToSql에 대한 클래스를 생성 말하는 당신이 부분 클래스에서

public partial class YourLinqToSqlClass : IEnumerable 
{ 
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 
    { 
     //Implement... 
    } 

} 
2

내 Linq에 SQL로 클래스는 IEnumerable 또는 개체를 IEnumerable 어떻게해야합니까

public class Widget{} 
public class WidgetCollection : IEnumerable<Widget> 
{ 
    public IEnumerator<Widget> GetEnumerator() 
    { 
     throw new NotImplementedException(); 
    } 

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 
    { 
     return this.GetEnumerator(); 
    } 

} 

질문의 두 번째 부분에 관해서, 나는 당신이 무엇에 대해 묻고 있는지 또는 시도하려고하는지 확신하지 못합니다.

0

"내 Linq를 SQL 클래스 IEnumerable로 만드십시오."라는 의미가 확실하지 않습니다. 그러나 컨트롤러에 ...이 경우

WidgetDataContext dataContext = new WidgetDataContext(); 

var data = dataContext.Widgets.OrderBy(x => x.name); 

return View(data); 

을 (ASP.NET MVC 가정), 뷰는 단순히 IEnumerable<Widget>로 (뷰에서 Model을라고도 함) data 개체를 캐스팅 할 수 있으며 foreach는 할 수 있습니다 그것의 길.

위의 조쉬의 답변으로이 질문을 보내주십시오. 심각하게, 세부 카운트 - 오른쪽 빈칸을 채워 클릭 "인터페이스를 구현"