数据库连接自动释放
来源:互联网 发布:金山软件招聘信息 编辑:程序博客网 时间:2024/06/06 20:09
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());
}
}
}
}
0 0
- 数据库连接自动释放
- 数据库连接的释放模式分析
- 关于Hibernate数据库连接进程释放
- NSAutoreleasePool自动释放池
- IOS自动释放池
- iOS:自动释放问题?
- IOS自动释放池
- 自动释放池NSAutoReleasePool
- 自动释放池autoreleasepool
- 自动释放池
- 自动释放池,
- 自动释放池 (autoReleasePool)
- 自动释放池
- iOS---自动释放池
- 自动释放池
- 自动释放池
- 自动释放池autoreleasepool
- 自动释放池
- iOS开发中,解决警告ld: warning: directory not found for option '-L/Users/Desktop/Universal'
- java 计算生日
- android studio 编译so文件入门(ndk配置及demo)1
- Feddler
- SVN密码重置
- 数据库连接自动释放
- linux下不区分大小写的搜索
- 使用Atom编辑文本文件
- C# Ping网络是否通
- android APK Expansion Files
- 图解 Android 事件分发机制
- Java常用的八种排序算法与代码实现
- 最受欢迎的开源库整理
- 命令行编译java工程项目 javax.servlet