• 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();
  • 相关阅读:
    ES6语法:var、let、const的区别详解
    idea新建springboot项目
    Serlvet之cookie和session学习
    常见排序算法
    Spring MVC拦截器学习
    分组数据
    redis数据库学习
    redis实现排行榜
    redis整合springboot的helloworld
    dubbo整合springboot最详细入门教程
  • 原文地址:https://www.cnblogs.com/netcasewqs/p/581251.html
Copyright © 2020-2023  润新知