/// <summary>
        /// Verilen Domain Object'i kurallara göre doğrulama yapar.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="DomainObject"></param>
        /// <returns></returns>
        public static bool IsValid <T>(T DomainObject)
        {
            ErrorList.Clear();
            // Kural Listesi
            List <BaseRule> Rules                = new List <BaseRule>();
            bool            result               = true;
            Type            types                = DomainObject.GetType();
            AutoContext     db                   = new AutoContext();
            string          className            = types.AssemblyQualifiedName;
            DAIList <DAI_VALIDATION_RULES> rules = db.Rules.ToList();

            foreach (var item in rules)
            {
                if (item.ClassName == className)
                {
                    Rules.Add(getRule(item.ClassName, item.FieldName, item.RuleName, item.ErrorMessage, item.OtherParams));
                }
            }

            foreach (var rule in Rules)
            {
                if (!rule.Validate(DomainObject))
                {
                    result = false;
                    ErrorList.Add(rule.Error);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public void WhereClause()
        {
            AutoContext       db       = new AutoContext();
            DAIList <Product> products = new DAIList <Product>();

            products = db.Product.Where(i => i.Id == 1 && i.ProductName == "Mac" || i.CategoryId != 3).ToList();
        }
Exemplo n.º 3
0
        public void ContextExtensionTest()
        {
            ConfigurationManager.ConnectionStrings["DEFAULT"].ToString();
            AutoContext        db   = new AutoContext();
            DAIList <Category> cats = db.Category.Where(i => i.Id == 8).ToList();
            DbContext          a    = new DbContext();

            a.Adi = "dai";
            a.TransformText();
        }
Exemplo n.º 4
0
        public void Update()
        {
            OrmEngine.Instance().InitializeDatabase();
            AutoContext        db         = new AutoContext();
            DAIList <Category> categories = db.Category.ToList();
            Category           category   = categories[0];

            category.CategoryName = "pc3";

            db.Category.Update(category);
            //provider.Update(new Product() { Id = 2, ProductCode = "Ali", ProductName= "Kaya" });
            db.SaveChanges();
        }
Exemplo n.º 5
0
        public void CodeGeneration()
        {
            List <Category> dai = new List <Category>();
            //Category a = new Category();
            //a.CategoryCode = "dai";
            //DbContext context = new DbContext();

            //OrmEngine.Instance().InitializeDatabase();
            //Product b = new Product();
            //b.ProductCode = "a";
            //context.Product.Add(b);
            //DAIList<Product> cat = context.Product.Where(p => p.ProductCode == "a");

            AutoContext        db  = new AutoContext();
            DAIList <Category> cat = db.Category.Where(p => p.CategoryName == "mac");

            DAIList <Product> Products = db.Product.ToList().OrderByDescending(p => p.Id);
            Product           a        = Products[0];
            var b = a.Categories;
        }
Exemplo n.º 6
0
 public void RelationMap()
 {
     AutoContext        db       = new AutoContext();
     DAIList <Product>  products = db.Product.ToList();
     DAIList <Category> cat      = products[0].Categories;
 }
Exemplo n.º 7
0
 public void GroupBy()
 {
     AutoContext        db   = new AutoContext();
     DAIList <Category> cats = db.Category.GroupBy(i => i.CategoryName);
 }
Exemplo n.º 8
0
 public void OrderByDesc()
 {
     AutoContext       db  = new AutoContext();
     DAIList <Product> prs = db.Product.OrderByDescending(i => i.ProductName);
 }
 public void WhereClause()
 {
     AutoContext db = new AutoContext();
     DAIList<Product> products = new DAIList<Product>();
     products = db.Product.Where(i => i.Id == 1 && i.ProductName == "Mac" || i.CategoryId != 3).ToList();
 }