1. 程式人生 > >Model層,介面層,工廠層

Model層,介面層,工廠層

//model層

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FK.Month.Test.Model
{
[Table("ProductInfo")]
public class ProductInfo
{
[Key]
public int ID { get; set; }

public string ProductTitle { get; set; }
public int OrderBy { get; set; }
public decimal Price { get; set; }
public string Files { get; set; }
public string Content { get; set; }
public DateTime? BeginTime { get; set; }
public int State { get; set; }
}
}

 

//介面層

using FK.Month.Test.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace FK.Month.Test.IDAL
{
public interface ICommon
{
int Add(ProductInfo m);
int Del(int ID);
int Dels(string IDs);
int Update(ProductInfo m);
int UpdateState(int ID, int State);
ProductInfo Fill(int ID);
List<ProductInfo> Show(Expression<Func<ProductInfo, bool>> Where);


}
}

//工廠層

                   //ef工廠

using FK.Month.Test.DAL;
using FK.Month.Test.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FK.Month.Test.Factory
{
public class EFFactory : SumFactory
{
public override ICommon CreateCommonDal()
{
return new CommonDal();
}
}
}

 

    //表工廠

using FK.Month.Test.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FK.Month.Test.Factory
{
public abstract class SumFactory
{
public abstract ICommon CreateCommonDal();
public static SumFactory GetFactory()
{
//返回EF工廠
return new EFFactory();
}
}
}