public void InitData()
 {
     if (_provider.GetQuery().Count() == 0)
     {
         _provider.Add(_models);
     }
 }
        //如果要添加额外的条件,可以使用此方法
        //public override JsonResult GetData()
        //{
        //    var jr = base.GetData();
        //    IQueryable<SupplierModel> query = jr.Data as IQueryable<SupplierModel>;

        //    jr.Data = query.Where(t => t.Level >= SupplierLevel.Medium);
        //    return jr;
        //}
        public override JsonResult GetUserDefineList(string prop)
        {
            if (prop == "ContacterId")
            {
                ModelDataService <PersonModel, Person> persons = SiteManager.Get <ModelDataService <PersonModel, Person> >();
                var linked = persons.GetQuery()
                             .Select(p => new
                {
                    id   = p.Id,
                    text = p.Name
                });

                return(Json(linked, JsonRequestBehavior.AllowGet));
            }
            return(base.GetUserDefineList(prop));
        }
Esempio n. 3
0
        public void TestLangModelRead()
        {
            //SiteManager.Kernel.Bind<IModelEntityConverter<TestLangTableModel, TestLangTable>>().To<LangTableConveter>();
            //Mapper.CreateMap<TestLangTable, TestLangTableModel>().ForMember(d => d.Remark, opt => opt.MapFrom(s => "RemarkTest"));
            ResHelper.CurrentCultureName = "zh-cn";

            ModelDataService <TestLangTableModel, TestLangTable> langService = new ModelDataService <TestLangTableModel, TestLangTable>(new EFAuditDataService <TestLangTable>(new LangContext()));
            var query = langService.GetQuery().Where(t => t.Name == "张");
            int count = query.Count();
            List <TestLangTableModel> list = query.ToList();

            Assert.IsTrue(count > 0);

            ResHelper.CurrentCultureName = "en-us";
            langService = new ModelDataService <TestLangTableModel, TestLangTable>(new EFAuditDataService <TestLangTable>(new LangContext()));
            query       = langService.GetQuery().Where(t => t.Name == "Zhang");
            list        = query.ToList();
            count       = query.Count();
            Assert.IsTrue(count > 0);
        }
Esempio n. 4
0
 public JsonResult GetData()
 {
     return(Json(_dataService.GetQuery(), JsonRequestBehavior.AllowGet));
 }