1、将数据显示在界面上
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
Session session
=
new
Session();
session.ConnectionString = " Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa " ;
session.Connect();
// 将数据显示在界面上
XPCollection xpc = new XPCollection(session, typeof (News));
this .gridControl1.DataSource = xpc;
session.ConnectionString = " Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa " ;
session.Connect();
// 将数据显示在界面上
XPCollection xpc = new XPCollection(session, typeof (News));
this .gridControl1.DataSource = xpc;
将实体类数据提交到数据库中
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
Session session
=
new
Session();
session.ConnectionString = " Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa " ;
session.Connect();
News news = new News(session); // public class News : XPObject {}
news.Title = " 标题 " ;
news.Content = " 内容 " ;
news.Pub_Name = " 发布人 " ;
news.Pub_Date = Convert.ToDateTime( " 2010-5-7 " );
news.Save(); // 提交到数据库
session.ConnectionString = " Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa " ;
session.Connect();
News news = new News(session); // public class News : XPObject {}
news.Title = " 标题 " ;
news.Content = " 内容 " ;
news.Pub_Name = " 发布人 " ;
news.Pub_Date = Convert.ToDateTime( " 2010-5-7 " );
news.Save(); // 提交到数据库