ORM新思路

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

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

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

        }get

    } input


}string

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

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

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

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

 

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;        }    }}

相關文章
相關標籤/搜索