{
return new Field[] { _.ProductID}; }
///
public override Field[] GetFields() {
return new Field[] { _.ProductID, _.ProductName, _.SupplierID, _.CategoryID, _.QuantityPerUnit, _.UnitPrice, _.UnitsInStock, _.UnitsOnOrder, _.ReorderLevel, _.Discontinued}; }
///
public override object[] GetValues() {
return new object[] { this._ProductID, this._ProductName, this._SupplierID, this._CategoryID, this._QuantityPerUnit, this._UnitPrice, this._UnitsInStock, this._UnitsOnOrder, this._ReorderLevel, this._Discontinued}; }
///
public override void SetPropertyValues(IDataReader reader) {
this._ProductID = DataUtils.ConvertValue
9
this._ProductName = DataUtils.ConvertValue
DataUtils.ConvertValue
this._UnitPrice = DataUtils.ConvertValue
///
public override void SetPropertyValues(DataRow row) {
this._ProductID = DataUtils.ConvertValue
this._ProductName = DataUtils.ConvertValue
DataUtils.ConvertValue
this._UnitPrice = DataUtils.ConvertValue
#endregion
#region _Field ///
public readonly static Field All = new Field(\,\); public readonly static Field ProductID = new Field(\,\,\);
public readonly static Field ProductName = new Field(\,\,\);
public readonly static Field SupplierID = new Field(\,\,\);
public readonly static Field CategoryID = new
10
Field(\,\,\);
public readonly static Field QuantityPerUnit = new Field(\,\,\); public readonly static Field UnitPrice = new Field(\,\,\);
public readonly static Field UnitsInStock = new Field(\,\,\);
public readonly static Field UnitsOnOrder = new Field(\,\,\);
public readonly static Field ReorderLevel = new Field(\,\,\);
public readonly static Field Discontinued = new Field(\,\,\); }
#endregion } }
Êý¾Ý×é¼þĬÈÏÈë¿ÚΪ£ºHxj.Data.DbSession.Default »á×Ô¶¯¶ÁÈ¡configÎļþÖÐconnectionStrings½ÚµãµÄ×îºóÒ»¸öÁ¬½ÓÅäÖᣠµ±È»¿É¸ù¾Ý²»Í¬µÄÊý¾ÝÁ¬½ÓʵÀý»¯ÐµÄDbSession¡£ ²éѯʾÀý£º
1¡¢²éѯProducts±íËùÓÐÊý¾ÝµÄÐÅÏ¢£¬·µ»ØÊµÌåÁÐ±í¡£
List
2¡¢²éѯÆäËûµÄ¼òµ¥Ê¾Àý¡£
DbSession.Default.From
//.Select(Products._.ProductID)
//.GroupBy(Products._.CategoryID.GroupBy && Products._.ProductName.GroupBy) // .InnerJoin
//.Where((Products._.ProductName.Contain(null) && Products._.UnitPrice > 1) || Products._.CategoryID == 2)
//.UnionAll(DbSession.Default.From
11
//.ToList(); .ToDataSet();
Ìí¼ÓʾÀý:
Àý×ÓÊÇwebϵġ£
//н¨Ò»¸öʵÌå
Products p = new Products();
//¿ªÆôÐÞ¸Ä (¿ªÆôÐ޸ĺóµÄÌí¼Ó²Ù×÷½«Ö»insert¸³Öµ¹ýµÄ×Ö¶Î) p.Attach();
//»ñÈ¡Ò³ÃæÖÐÊäÈëµÄÖµ
EntityUtils.UpdateModel
//·µ»ØÖµ Èç¹ûÓÐ×ÔÔö³¤×ֶΣ¬Ôò·µ»Ø×ÔÔö³¤×ֶεÄÖµ
int returnValue = DbSession.Default.Insert
ÐÞ¸ÄʾÀý£º
ÐÞ¸ÄProducts±íµÚÒ»ÌõÊý¾ÝµÄProductNameµÄÖµ¡£
//»ñÈ¡Products±íµÚÒ»ÐÐ
Products p = DbSession.Default.From
//¿ªÆôÐÞ¸Ä (Ð޸IJÙ×÷֮ǰ ±ØÐëÖ´Ðд˷½·¨) p.Attach();
p.ProductName = txtValue.Text.Trim(); //¸üÐÂ
//·µ»Ø0±íʾ¸üÐÂʧ°Ü ×é¼þÓÐÊÂÎñ»á×Ô¶¯»Ø¹ö //·µ»Ø1±íʾ¸üгɹ¦
//¸üгɹ¦·µ»ØÖµ¾ÍÊÇÊÜÓ°ÏìµÄÌõÊý
int returnvalue = DbSession.Default.Update
ɾ³ýʾÀý£º
²ÎÊýΪÖ÷¼üµÄÖµ£¬Ò²¿É´«ÈëʵÌå¡£
//ɾ³ý Ìõ¼þ ProductID=2
//·µ»Ø0±íʾɾ³ýʧ°Ü ×é¼þÓÐÊÂÎñ»á×Ô¶¯»Ø¹ö //·µ»Ø1±íʾɾ³ý³É¹¦
//ɾ³ý³É¹¦·µ»ØÖµ¾ÍÊÇÊÜÓ°ÏìµÄÌõÊý
int returnvalue = DbSession.Default.Delete
×é¼þ»¹Ö§³ÖÊÂÎñ£¬Åú´¦ÀíµÈ¹¦ÄÜ¡£
12