zoukankan      html  css  js  c++  java
  • ORM新思路

      public interface ICalculator
        {
            String Calculate(String input);
        }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.Composition;

    namespace WebApplication3
    {
        [Export(typeof(ICalculator))]
        public class MySimpleCalculator : ICalculator
        {
            public string Calculate(string input)
            {
                return "MySimpleCalculator 处理了" + input;

            }

        }


    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.Composition.Hosting;
    using System.ComponentModel.Composition;
    using System.Reflection;

    namespace WebApplication3
    {
        public class ComposCLass
        {
            private CompositionContainer _container;
            [Import]
            public ICalculator calculator1{set;get;}
            [Import]
            public MODEL_Greef Member { set; get; }
            public ComposCLass()
            {
                Compose();
            }

            public void Compose()
            {
                var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

                _container = new CompositionContainer(catalog);
                try
                {
                    this._container.ComposeParts(this);
                }
                catch (CompositionException compositionException)
                {
                }
            }
        }
    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel.Composition;
    using System.ComponentModel.Composition.Hosting;
    using System.Reflection;

    namespace WebApplication3
    {
        public class MYORM
        {
            private CompositionContainer _container;
          
            public String MysqlStr = "";
            [Import]
            public MODEL_Greef Member { set; get; }
            public MYORM()
            {
                this.MysqlStr = "Select * from Userinfo where ";
                Compose();
            }
            public void Compose()
            {
                var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

                _container = new CompositionContainer(catalog);
                try
                {
                    this._container.ComposeParts(this);
                }
                catch (CompositionException compositionException)
                {
                }
            }
            public MYORM(String SQLStr)
            {
                if (SQLStr.ToString().Length > 0)
                {
                    this.MysqlStr = this.MysqlStr + SQLStr;
                }
                else
                {
                    this.MysqlStr =   "Select * from Userinfo where ";
            
                }
              
            }

            public MYORM ORM_On (String Where)
            {
                this.MysqlStr = this.MysqlStr+ Where;


                return new MYORM(MysqlStr);

            }

            public MYORM ORM_AND(String Where)
            {
                this.MysqlStr = this.MysqlStr + Where;


                return new MYORM(MysqlStr);

            }

            public MYORM  And (String Where)
            {
                this.MysqlStr = this.MysqlStr + Where;


                return new MYORM(MysqlStr);

            }

            public static MYORM operator >(MYORM compare, String Value)
            {
                compare.MysqlStr = (compare.MysqlStr.ToString() + ">" + Value.ToString()).ToString();
                return compare;
            }
            public static MYORM operator <(MYORM compare, String Value)
            {
                compare.MysqlStr = (compare.MysqlStr.ToString() + "<" + Value.ToString()).ToString();
                return compare;
            }
        }
    }

  • 相关阅读:
    由自身经历谈“不谋全局者,不足以谋一域”
    MySQL 常用SQL语句
    举例说明android中ListPreference的使用方法
    cookie机制和session机制的区别
    thinkphp浏览历史功能实现方法
    利用PHP获取访客IP、地区位置、浏览器及来源页面等信息
    PHP+Ajax点击加载更多内容 -这个效果好,速度快,只能点击更多加载,不能滚动自动加载...
    php用正则表达式匹配URL的简单方法(亲测可行)
    PHP实现记录浏览历史页面
    [译] 流言终结者 —— “SQL Server 是Sybase的产品而不是微软的”
  • 原文地址:https://www.cnblogs.com/greefsong/p/3142656.html
Copyright © 2011-2022 走看看