CodehighlightingproducedbyActiproCodeHighlighter(freeware)
http://www.CodeHighlighter.com/<" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Gentle.net Framework 入門二(基礎示例)

系統 1920 0
1. 一個基本的示例

通過該示例可以撐握以下內容:

1) Gentle.net 是怎么把對象(類)和關系數據庫 (SQL) 關聯起來的 .

2) 使用 Gentle.net 插入,更新,返回實例信息,和刪除數據 .

本示例中以人為實例,包括人 ID 和姓名 . 附上建表腳本

示例表代碼
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> if exists(select * fromdbo.sysobjectswhereid = object_id(N ' [dbo].[Peoples] ' )andOBJECTPROPERTY(id,N ' IsUserTable ' ) = 1 )
droptable[dbo].[Peoples]
GO

CREATETABLE[dbo].[Peoples](
[PeopleID][
int ]IDENTITY( 1 , 1 )NOTNULL,
[PeopleName][
char ]( 10 )COLLATEChinese_PRC_CI_ASNOTNULL
)ON[PRIMARY]
GO

接著附上代碼,相關使用請看代碼。

<!-- google_ad_client = "pub-6628499292856412"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; google_ad_channel = ""; google_color_border = "000000"; google_color_bg = "FFFFFF"; google_color_link = "191919"; google_color_text = "000000"; google_color_url = "008000"; //-->
示例代碼
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> using System;
using Gentle.Framework;

namespace ConGentleStudy
{
/**/ /// <summary>
/// BaseExample的摘要說明。
/// </summary>

public class BaseExample
{
[STAThread]
static void Main( string []args)
{
Console.WriteLine(
" 創建人實例。 " );
Peoplespeople
= new Peoples( " xuanfeng " );
Console.WriteLine(
" 創建人實例。 " );
Broker.Insert(people);
Console.WriteLine(
" 創建人實例。 " );
people.PeopleName
= " peizunyou " ;
Console.WriteLine(
" 更新人的信息。 " );
Broker.Update(people);
Console.WriteLine(
" 創建返回實例信息的Key! " );
Keykey
= new Key( " Peoples " , typeof (Peoples), true , " PeopleName " , " peizunyou " );
Console.WriteLine(key.Count.ToString());

Console.WriteLine(
" 創建人實例! " );
Peoplespeople1
= new Peoples(); // 必須先實例化申請到空間,下步才不會出錯。
people1.PeopleName = " xiamfe " ;
Console.WriteLine(
" 返回一個人實例的信息! " );
// Peoplespeople1=(Peoples)Broker.RetrieveInstance(typeof(Peoples),key),這樣是將出錯
people1 = (Peoples)Broker.RetrieveInstance( typeof (Peoples),key); // 返回一個實例信息。
Console.WriteLine( " 輸出人的姓名 " );
Console.WriteLine(people1.PeopleName);
Console.WriteLine(
" 刪除信息! " );
Keykey_rem
= new Key( typeof (Peoples), true , " PeopleID " ,people1.PeopleID);
Broker.Remove(
typeof (Peoples),key_rem); // 主意,Key中提供的字段PeopleID是表中的主鍵,刪除才有效!

Console.WriteLine(
" 演示完成,按任何鍵退出! " );
Console.Read();

}


}



[TableName(
" Peoples " )]
public class Peoples
{
string name;
int id;
public Peoples( int _id, string _name)
{
this .name = _name;
this .id = _id;
}

public Peoples( string _name)
{
this .name = _name;
}

public Peoples()
{

}

[TableColumn(
" PeopleID " , true ),PrimaryKey(AutoGenerated = true )]
public int PeopleID
{
get { return this .id;}
set { this .id = value;}
}

[TableColumn(
" PeopleName " , true )]
public string PeopleName
{
get { return this .name;}
set { this .name = value;}
}


}

}

Gentle.net Framework 入門二(基礎示例)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 什邡市| 东海县| 鄯善县| 罗江县| 奈曼旗| 嘉兴市| 宜宾县| 太白县| 富平县| 鄄城县| 绥棱县| 临潭县| 曲水县| 新邵县| 抚宁县| 壤塘县| 望都县| 黄石市| 天镇县| 锦屏县| 靖安县| 斗六市| 射阳县| 龙门县| 武清区| 东阳市| 田林县| 镇原县| 宁晋县| 磐安县| 松阳县| 龙岩市| 明溪县| 双牌县| 神农架林区| 宜城市| 博爱县| 五大连池市| 青龙| 黔江区| 连城县|