DbContext.ObjectContext
에 직접 전화 할 수없는 이유는 무엇입니까? 나는이 ((IObjectContextAdapter)context).ObjectContext
DbContext.ObjectContext를 직접 호출 할 수없는 이유는 무엇입니까?
내가 내부 메커니즘은 내가 IEnumerable<T>
상속 IEnumerable
인하기 전에이 문제를 충족이
class Program
{
static void Main(string[] args)
{
TestClass t = new TestClass();
((TestInterface)t).TestMethod();
// I can't call t.TestMethod()
Console.ReadKey();
}
}
public interface TestInterface
{
void TestMethod();
}
public class TestClass : TestInterface
{
void TestInterface.TestMethod()
{
Console.WriteLine("abcdefg");
}
}
같은 인터페이스의 암시 적으로 구현 생각 할 수있는, 그것은 일반 버전 IEnumerator<T> GetEnumerator()
및 제네릭이 아닌이있다 버전 IEnumerator GetEnumerator()
이지만 일반이 아닌 일반 전화 만 호출 할 수 있습니다. 그 이유는 비 제네릭 타입이 타입에 안전하지 않고 작성자가 그것을 숨기고 싶어하기 때문입니다.
하지만 DbContext 클래스의 이유는 무엇입니까?
IEnumerable을 IEnumerable으로 변환하려면 OfType 또는 캐스트 을 호출해야합니다. –
Pawel