日期:2014-05-17 浏览次数:21169 次
using (DAL.PrintsysEntities db = new DAL.PrintsysEntities()) {
System.Data.Common.DbConnection conn = db.Connection;
using (System.Data.Common.DbCommand cmd = conn.CreateCommand()) {
cmd.CommandText = "select now()";
if (conn.State != ConnectionState.Open)
conn.Open();
using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader()) {
if (reader.Read()) {
object now = reader.GetDateTime(0);
}
}
}
}
void Main()
{
var constr = @"Data Source=.;Initial Catalog=Northwind;Integrated Security=True";
var context = new DataContext(constr) ;
string[] ss=context.ExecuteQuery<string>("select now()").ToArray();
foreach(string s in ss)
{
Console.WriteLine(s);
}
}