문제

Simple question - where is dbContext.CreateQuery method in Entity Framework 6 and if the answer is there is not such method my question is what to do to get some data by SQL query to an objectQuery?

올바른 솔루션이 없습니다

다른 팁

Cast context to IObjectContextAdapter and use ObjectContext, e.g.:

        using (var context = new AdventureEntities())
        {
            string eSql = "SELECT VALUE c FROM AdventureEntities.Customer AS c ORDER BY c.LastName";
            var query = ((IObjectContextAdapter)context).ObjectContext.CreateQuery<Customer>(eSql);
            var customers = query.ToList();
            foreach (Customer customer in customers)
            {
                Console.WriteLine("{0}, {1}", customer.FirstName, customer.LastName);
            }
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top