Ndo 新版本发布

      这个版本的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操作代码如下:
INDOManager nm = NDOManager.Instance;
            EntityShipper shipper 
= new EntityShipper();
            shipper.CompanyName 
= "NDO Test";
            shipper.Phone 
= "(101)  555-6666";

            
//insert a shipper record
            nm.Save(shipper);
            Console.WriteLine(shipper.ShipperID);

            EntityShipper shipper2 
= nm.Load(typeof(EntityShipper),shipper.ShipperID) as EntityShipper;
            Console.WriteLine(
" CompanyName = {0}\t Phone = {1} ",
                (
string)shipper2.CompanyName,
                (
string)shipper2.Phone);


            
//update shipper record
            shipper2.CompanyName = "update ndo test!";
            shipper2.Phone 
= "(101) 666-8888";
            nm.Save(shipper2);

            EntityShipper shipper3 
= nm.Load(typeof(EntityShipper),shipper.ShipperID) as EntityShipper;
            Console.WriteLine(
" CompanyName = {0}\t Phone = {1} ",
                (
string)shipper3.CompanyName,
                (
string)shipper3.Phone);


            
//delete a shipper
            nm.Delete(shipper3);

            
//check delete result
            EntityShipper shipper4 =  nm.Load(typeof(EntityShipper),shipper.ShipperID) as EntityShipper;
            Console.WriteLine(shipper4.CompanyName 
== null || shipper4.CompanyName == "");
            Console.ReadLine();
posted @ 2006-12-04 11:03  风云  阅读(587)  评论(0编辑  收藏  举报