using System;
using System.Data.Common;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var entity = new ldhEntities())
            {
                var context = ((IObjectContextAdapter)entity).ObjectContext;
                string myQuery = @"select affairinfo.ID, affairinfo.NAME from affairinfo";
                var data = (new ObjectQuery<DbDataRecord>(myQuery, context)).ToList();

                foreach (DbDataRecord rec in data)
                {
                    Console.WriteLine("ID {0}; NAME {1}", rec[0], rec[1]);

                   //Console.WriteLine("ID {0}; NAME {1}", rec["ID"], rec["NAME"]);
                }
            }
            Console.Read();
        }
    }
}

相关文章:

  • 2021-08-03
  • 2021-10-06
  • 2021-08-18
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2021-07-25
  • 2022-12-23
  • 2021-08-26
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
相关资源
相似解决方案