示例#1
0
        protected IList<Model> Load(Queryset queryset = null)
        {
            if (queryset != null)
                queryset.Compile();

            IList<DbValue[]> rows = DbEngine.Select(ModelInfo, queryset);

            if (rows != null && rows.Count > 0)
            {
                List<Model> models = new List<Model>();
                foreach (DbValue[] row in rows)
                {
                    Model model = OrmManager.CreateNewModel(ModelInfo.ModelApp, ModelInfo.ModelType);
                    if (model != null)
                    {
                        foreach (DbValue dbValue in row)
                        {
                            Field field = model.GetFieldByDbName(dbValue.Column);
                            if (field != null)
                                model[field.Name] = field.FromDbValue(dbValue.Value);
                        }
                        model.Status = ModelStatus.Loaded;
                        models.Add(model);
                    }
                }

                return models;
            }

            return null;
        }
示例#2
0
        public IList ToList(string fieldName, Queryset queryset = null)
        {
            if (queryset != null)
                queryset.Compile();

            return DbEngine.ToList(ModelInfo, fieldName, queryset);
        }
示例#3
0
        public bool Delete(Queryset queryset)
        {
            if (queryset != null)
                queryset.Compile();

            return DbEngine.Delete(ModelInfo, queryset);
        }
示例#4
0
        public DataTable ToDataTable(string[] fieldNames, Queryset queryset = null)
        {
            if (queryset != null)
                queryset.Compile();

            return DbEngine.ToDataTable(ModelInfo, fieldNames, queryset);
        }
示例#5
0
        public long Count(Queryset queryset = null)
        {
            if (queryset != null)
                queryset.Compile();

            return DbEngine.SelectCount(ModelInfo, queryset);
        }