using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NewTest.Dao;
using Models;
using OracleSugar;
namespace NewTest
{
public partial class Form1 : Form, NewTest.Demos.IDemos
{
public Form1()
{
InitializeComponent();
}
public void Init()
{
var db = SugarDao.GetInstance();
try
{
using (db) //自动控制数据连接释放
{
object maxId = db.Queryable<Student>().Max(it => it.id);
int a = 2 / Convert.ToInt16("0");
List<Student> list = db.Queryable<Student>().Where(it => (it.name.ToString().Contains("小") && it.id > 6)).ToList();
Console.WriteLine(db.Queryable<Student>().ToSql<Student>().Key[0]);
System.Diagnostics.Debug.WriteLine(db.GetConnection().State);
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine("当前连接:"+db.GetConnection());
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NewTest.Dao;
using Models;
using OracleSugar;
namespace NewTest
{
public partial class Form1 : Form, NewTest.Demos.IDemos
{
public Form1()
{
InitializeComponent();
}
public void Init()
{
var db = SugarDao.GetInstance();
try
{
using (db) //自动控制数据连接释放
{
object maxId = db.Queryable<Student>().Max(it => it.id);
int a = 2 / Convert.ToInt16("0");
List<Student> list = db.Queryable<Student>().Where(it => (it.name.ToString().Contains("小") && it.id > 6)).ToList();
Console.WriteLine(db.Queryable<Student>().ToSql<Student>().Key[0]);
System.Diagnostics.Debug.WriteLine(db.GetConnection().State);
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine("当前连接:"+db.GetConnection());
}
}
}
}