Esempio n. 1
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="saveType"></param>
        /// <returns></returns>
        public virtual NewsEntity CreateEntity(SaveType saveType)
        {
            var entity = new NewsEntity
            {
                Title    = string.IsNullOrWhiteSpace(Title) ? "" : Title,
                Content  = string.IsNullOrWhiteSpace(Content) ? "" : Content,
                Sequence = Sequence == null?1: Sequence.Value,
                IsShow   = IsShow == null ? true : IsShow.Value,
                SaveType = saveType
            };

            if (saveType == SaveType.Modify)
            {
                entity.Id = Id.Convert <long>();
                if (Title != null)
                {
                    entity.SetProperty(it => it.Title);
                }
                if (Content != null)
                {
                    entity.SetProperty(it => it.Content);
                }
                if (Sequence != null)
                {
                    entity.SetProperty(it => it.Sequence);
                }
                if (IsShow != null)
                {
                    entity.SetProperty(it => it.IsShow);
                }
            }
            return(entity);
        }