这个版本的Ndo对视图的支持增强了,并且增强对实体类的单表映射,下个版本将增加对一对多关联关系的支持!
      简单介绍一下,实体类的使用方法:
using System;
using NDO;

namespace NDOShippers
{
    
public class EntityShipper:Entity
    {
        
        
public EntityShipper():base("Shippers")
        {
        }
        
        
public override NDO.Entity NewInstance()
        {
            
return new EntityShipper();
        }
        

        
public int ShipperID
        {  
            
get { return this.settings.GetInt32("ShipperID"); }
            
set { this["ShipperID"= value; }
        }
        
public string CompanyName
        {  
            
get { return (string)this["CompanyName"]; }
            
set { this["CompanyName"= value; }
        }
        
public string Phone
        {  
            
get { return (string)this["Phone"]; }
            
set { this["Phone"= value; }
        }
        
        
    }
}

Shipper 类的CRUD操作代码如下:
Ndo 新版本发布INDOManager nm = NDOManager.Instance;
Ndo 新版本发布            EntityShipper shipper 
= new EntityShipper();
Ndo 新版本发布            shipper.CompanyName 
= "NDO Test";
Ndo 新版本发布            shipper.Phone 
= "(101)  555-6666";
Ndo 新版本发布
Ndo 新版本发布            
//insert a shipper record
Ndo 新版本发布
            nm.Save(shipper);
Ndo 新版本发布            Console.WriteLine(shipper.ShipperID);
Ndo 新版本发布
Ndo 新版本发布            EntityShipper shipper2 
= nm.Load(typeof(EntityShipper),shipper.ShipperID) as EntityShipper;
Ndo 新版本发布            Console.WriteLine(
" CompanyName = {0}\t Phone = {1} ",
Ndo 新版本发布                (
string)shipper2.CompanyName,
Ndo 新版本发布                (
string)shipper2.Phone);
Ndo 新版本发布
Ndo 新版本发布
Ndo 新版本发布            
//update shipper record
Ndo 新版本发布
            shipper2.CompanyName = "update ndo test!";
Ndo 新版本发布            shipper2.Phone 
= "(101) 666-8888";
Ndo 新版本发布            nm.Save(shipper2);
Ndo 新版本发布
Ndo 新版本发布            EntityShipper shipper3 
= nm.Load(typeof(EntityShipper),shipper.ShipperID) as EntityShipper;
Ndo 新版本发布            Console.WriteLine(
" CompanyName = {0}\t Phone = {1} ",
Ndo 新版本发布                (
string)shipper3.CompanyName,
Ndo 新版本发布                (
string)shipper3.Phone);
Ndo 新版本发布
Ndo 新版本发布
Ndo 新版本发布            
//delete a shipper
Ndo 新版本发布
            nm.Delete(shipper3);
Ndo 新版本发布
Ndo 新版本发布            
//check delete result
Ndo 新版本发布
            EntityShipper shipper4 =  nm.Load(typeof(EntityShipper),shipper.ShipperID) as EntityShipper;
Ndo 新版本发布            Console.WriteLine(shipper4.CompanyName 
== null || shipper4.CompanyName == "");
Ndo 新版本发布            Console.ReadLine();

相关文章: