예제 #1
0
        /// <summary>
        /// Gets the name of the table.
        /// </summary>
        /// <returns></returns>
        private string GetTableName(GetSourceTypeEnum sourceType)
        {
            if (sourceType == GetSourceTypeEnum.Table)
            {
                return(this.Entity.ClassName);
            }
            else
            {
                return("v" + this.Entity.ClassName);
            }

            //string entitySetName = this.Entity.EntityName;
            //Check.Require(string.IsNullOrEmpty(entitySetName) == false);

            //if (entitySetName.IndexOf(".") < 0)
            //{
            //    return entitySetName;
            //}
            //else
            //{
            //    char[] ch = new char[1];
            //    ch[0] = '.';
            //    string[] sepname = this.Entity.EntityName.Split(ch);
            //    string tableName = sepname[1];
            //    //if (string.IsNullOrEmpty(this.Entity.Schema) == false)
            //    //    tableName = this.Entity.Schema + "_" + tableName;
            //    return tableName;
            //}
        }
예제 #2
0
        /// <summary>
        /// Gets the entity context.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static EntityObjectBase GetEntityObject(string entityName, GetSourceTypeEnum sourceType)
        {
            string           cacheKey = entityName + ((int)sourceType);
            EntityObjectBase obj      = _EntityObjectCache.GetOrCreate(cacheKey, (x) => GetEntityFactory(entityName).GetEntityObject(entityName, sourceType), null);

            return((EntityObjectBase)FWUtils.ReflectionUtils.CloneByFirstConstructor(obj.GetType()));
            //return GetEntityFactory(entityName).GetEntityObject(entityName, sourceType);
        }
예제 #3
0
        public void ConvertStringToObjectEnumByValue()
        {
            EntityUtils       target = new EntityUtils();
            GetSourceTypeEnum testE  = GetSourceTypeEnum.View;
            object            result = target.ConvertStringToObject(((int)testE).ToString(), testE.GetType());

            Assert.AreEqual(testE, result);
        }
예제 #4
0
        /// <summary>
        /// Gets the entity object.
        /// </summary>
        /// <param name="entityName">Name of the entity.</param>
        /// <param name="sourceType">Type of the source.</param>
        /// <returns></returns>
        public EntityObjectBase GetEntityObject(string entityName, GetSourceTypeEnum sourceType)
        {
            ApplicationSetting appSetting = FWUtils.ConfigUtils.GetAppSettings();
            object             obj        = null;

            if (sourceType == GetSourceTypeEnum.Table)
            {
                obj = FWUtils.ReflectionUtils.CreateInstance(appSetting.Project.NamespacePrefix + ".Common.EntityObjects", entityName, appSetting.Project.NamespacePrefix + ".Common");
            }
            else
            {
                obj = FWUtils.ReflectionUtils.CreateInstance(appSetting.Project.NamespacePrefix + ".Common.EntityObjects", "v" + entityName, appSetting.Project.NamespacePrefix + ".Common");
            }
            return((EntityObjectBase)obj);
        }
예제 #5
0
        protected System.Collections.IList ConvertToTypedList(GetSourceTypeEnum sourceType, ICollection <string> colNames, System.Collections.IList list)
        {
            System.Collections.IList resultList = null;
            if (sourceType == GetSourceTypeEnum.Table)
            {
                resultList = new List <T>();
            }
            else
            {
                resultList = new List <V>();
            }

            foreach (var item in list)
            {
                int    i   = 0;
                object obj = EntityFactory.GetEntityObject(this.EntityName, sourceType);
                foreach (string colName in colNames)
                {
                    //obj.GetType().GetProperty(fieldName)
                    if (item is object[])
                    {
                        object value = ((object[])item)[i];
                        FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, colName, obj, value);
                    }
                    else
                    // when we have only one column, then item is not object[]
                    {
                        object value = item;
                        FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, colName, obj, value);
                    }
                    i++;
                }
                resultList.Add(obj);
            }

            return(resultList);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetByFilterParameters"/> class.
        /// </summary>
        /// <param name="entityInfo">The entity info.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="sort">The sort.</param>
        /// <param name="pageIndex">Index of the page.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="selectColumns">The select columns.</param>
        public GetByFilterParameters(FilterExpression filter, SortExpression sort, int pageIndex, int pageSize, ICollection <string> selectColumns, GetSourceTypeEnum sourceType)
        {
            if (filter != null)
            {
                this.Filter = (FilterExpression)filter.Clone();
            }
            else
            {
                this.Filter = new FilterExpression();
            }

            if (sort != null)
            {
                this.Sort = (SortExpression)sort.Clone();
            }
            else
            {
                this.Sort = new SortExpression();
            }

            this.PageIndex     = pageIndex;
            this.PageSize      = pageSize;
            this.SelectColumns = selectColumns;
            this.SourceType    = sourceType;
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetByIDParameters"/> class.
 /// </summary>
 /// <param name="sourceType">Type of the source.</param>
 public GetByIDParameters(GetSourceTypeEnum sourceType)
     : this(sourceType, GetModeEnum.Get, LockModeEnum.None)
 {
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GetByIDParameters"/> class.
 /// </summary>
 /// <param name="getMode">The get mode.</param>
 /// <param name="lockMode">The lock mode.</param>
 public GetByIDParameters(GetSourceTypeEnum sourceType, GetModeEnum getMode, LockModeEnum lockMode)
 {
     _GetMode    = getMode;
     _LockMode   = lockMode;
     _SourceType = sourceType;
 }