.net使用自定義類屬性實(shí)例(2)_.Net教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:.NET實(shí)現(xiàn)在網(wǎng)頁(yè)中預(yù)覽Office文件的3個(gè)方法近日公司要搞一個(gè)日常的文檔管理的東東,可以上傳、下載各種文件,如果是office文件呢還必須得支持預(yù)覽功能,其他的都好說(shuō)但是唯獨(dú)office預(yù)覽功能比較麻煩,但是不能不做,廢話不多說(shuō)了一步步來(lái)吧。分析了下網(wǎng)易郵箱的文件預(yù)覽功能,他用的是微軟的組件,最早叫Office
代碼如下: [Table("Wincms_Dictionary")] ///映射到數(shù)據(jù)庫(kù)的Wincms_Dictionary表
public class Wincms_Dictionary : BaseEntity
{
private int _DictionaryId;
public Wincms_Dictionary()
{
}
[Field("DictionaryId",DbType.Int32)] ///映射到數(shù)據(jù)庫(kù)的Wincms_Dictionary表中的字段
public int DictionaryId
{
get { return this._DictionaryId; }
set
{
this._DictionaryId = value;
}
}
}
///基于實(shí)體類獲取實(shí)體對(duì)應(yīng)的表名稱和字段名稱
public class Test
{
public static void main(string[] args)
{
Wincms_Dictionary dict=new Wincms_Dictionary();
Console.WriteLine("表名稱:"+GetTableName(dict));
Console.WriteLine("字段名稱:"+GetFieldName(dict,"DictionaryId"));
Console.Read();
}
///獲取實(shí)體表名稱
public static string GetTableName(BaseEntity entity)
{
return entity.GetTableName();
}
///獲取實(shí)體字段名稱
public static string GetFieldName(BaseEntity entity,string propertyName)
{
FieldAttribute fieldAttribute=entity.GetFieldAttribute(propertyName);
return fieldAttribute.FieldName;
}
}
輸出結(jié)果為:
代碼如下: 表名稱:Wincms_Dictionary
字段名稱:DictionaryId
分享:asp.net中控制反轉(zhuǎn)怎么理解?對(duì)IOC的解釋為:Inversion of control is a common characteristic of frameworks, so saying that these lightweight containers are special because they use inversion of control is like saying my car is special because it has wheels. 我想對(duì)這一概念執(zhí)行
相關(guān).Net教程:
- .NET實(shí)現(xiàn)在網(wǎng)頁(yè)中預(yù)覽Office文件的3個(gè)方法
- asp.net中控制反轉(zhuǎn)怎么理解?
- delphi選擇文件夾例子
- asp.net中C++單例實(shí)現(xiàn)問(wèn)題分析
- 簡(jiǎn)單理解Web Service三種實(shí)現(xiàn)方式
- Asp.net中Ajax與JQuery的ready函數(shù)沖突怎么辦
- asp.net中Repeater控件用法筆記
- asp.net中導(dǎo)出excel數(shù)據(jù)的方法匯總
- Asp.Net 上傳圖片并生成高清晰縮略圖
- 服務(wù)器安全狗導(dǎo)致ASP.NET網(wǎng)站運(yùn)行出錯(cuò)的一個(gè)案例
- Asp.Net其他頁(yè)面如何調(diào)用Web用戶控件寫的分頁(yè)
- ASP.NET中上傳并讀取Excel文件數(shù)據(jù)示例
.Net教程Rss訂閱編程教程搜索
.Net教程推薦
- 用事實(shí)說(shuō)話!AJAX應(yīng)用程序開(kāi)發(fā)七宗罪
- ASP.NET 設(shè)計(jì)中的 N 個(gè)技巧
- 三層+存儲(chǔ)過(guò)程實(shí)現(xiàn)分頁(yè)示例代碼
- ASP.NET中Datagrid常見(jiàn)錯(cuò)誤
- 談對(duì)程序開(kāi)發(fā)中異常的處理
- 在.net中如何利用數(shù)據(jù)工廠實(shí)現(xiàn)多數(shù)據(jù)庫(kù)的操作
- 講解asp.net的異常處理機(jī)制
- c# 連接字符串?dāng)?shù)據(jù)庫(kù)服務(wù)器端口號(hào)
- 基于C#的接口基礎(chǔ)教程之二
- ASP.NET調(diào)用oracle存儲(chǔ)過(guò)程實(shí)現(xiàn)快速分頁(yè)
- 相關(guān)鏈接:
- 教程說(shuō)明:
.Net教程-.net使用自定義類屬性實(shí)例(2)
。