當前位置: 首頁>>代碼示例>>C#>>正文


C# ORM.EntityPropertyInfo類代碼示例

本文整理匯總了C#中wojilu.ORM.EntityPropertyInfo的典型用法代碼示例。如果您正苦於以下問題:C# EntityPropertyInfo類的具體用法?C# EntityPropertyInfo怎麽用?C# EntityPropertyInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityPropertyInfo類屬於wojilu.ORM命名空間,在下文中一共展示了EntityPropertyInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Validate

        public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
        {
            Object obj = target.get( info.Name );

            Boolean isNull = false;
            if (info.Type == typeof( String )) {
                if (obj == null) {
                    isNull = true;
                }
                else if (strUtil.IsNullOrEmpty( obj.ToString() )) {
                    isNull = true;
                }
            }
            else if (obj == null) {
                isNull = true;
            }

            if (isNull) {
                if (strUtil.HasText( this.Message )) {
                    result.Add( this.Message );
                }
                else {
                    EntityInfo ei = Entity.GetInfo( target );
                    String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
                    result.Add( str + "can not be null" );
                }
            }
        }
開發者ID:2014AmethystCat,項目名稱:wojilu,代碼行數:28,代碼來源:NotNullAttribute.cs

示例2: checkLength

 private static Boolean checkLength( EntityPropertyInfo info )
 {
     if (info.SaveAttribute == null) return false;
     if (info.SaveAttribute.LengthSetted() == false) return false;
     if (info.Type != typeof( String )) return false;
     return true;
 }
開發者ID:LeoLcy,項目名稱:cnblogsbywojilu,代碼行數:7,代碼來源:Validator.cs

示例3: addColumnSingle

 private void addColumnSingle( EntityInfo entity, StringBuilder sb, EntityPropertyInfo ep, String columnName ) {
     if (ep.Type == typeof( int )) {
         addColumn_Int( sb, ep, columnName );
     }
     else if (ep.Type == typeof( long )) {
         addColumn_Long( sb, columnName );
     }
     else if (ep.Type == typeof( DateTime )) {
         addColumn_Time( sb, columnName );
     }
     else if (ep.Type == typeof( decimal )) {
         addColumn_Decimal( entity, sb, ep, columnName );
     }
     else if (ep.Type == typeof( double )) {
         addColumn_Double( entity, sb, columnName );
     }
     else if (ep.Type == typeof( float )) {
         addColumn_Single( entity, sb, columnName );
     }
     else if (ep.Type == typeof( String )) {
         addColumn_String( entity, sb, ep, columnName );
     }
     else if (ep.IsEntity) {
         addColumn_entity( sb, columnName );
     }
 }
開發者ID:2014AmethystCat,項目名稱:wojilu,代碼行數:26,代碼來源:TableBuilderBase.cs

示例4: addColumn_Int

 protected override void addColumn_Int( StringBuilder sb, EntityPropertyInfo ep, String columnName ) {
     sb.Append( columnName );
     if (ep.Property.IsDefined( typeof( TinyIntAttribute ), false )) {
         sb.Append( " tinyint default 0, " );
     }
     else {
         sb.Append( " int default 0, " );
     }
 }
開發者ID:2014AmethystCat,項目名稱:wojilu,代碼行數:9,代碼來源:MySqlTableBuilder.cs

示例5: addColumn_ByColumnAttribute

 protected virtual void addColumn_ByColumnAttribute( EntityInfo entity, StringBuilder sb, EntityPropertyInfo ep, String columnName )
 {
     if (ep.SaveAttribute.Length < 255) {
         addColumn_ShortText( sb, columnName, ep.SaveAttribute.Length );
     }
     else if ((ep.SaveAttribute.Length > 255) && (ep.SaveAttribute.Length < 4000)) {
         addColumn_MiddleText( entity, sb, ep, columnName );
     }
     else {
         addColumn_LongText( entity, sb, columnName );
     }
 }
開發者ID:LeoLcy,項目名稱:cnblogsbywojilu,代碼行數:12,代碼來源:TableBuilderBase.cs

示例6: addColumn_Decimal

        protected override void addColumn_Decimal( EntityInfo entity, StringBuilder sb, EntityPropertyInfo ep, String columnName ) {
            if (ep.MoneyAttribute != null) {
                sb.Append( columnName );
                sb.Append( " currency default 0, " );
            }
            else {

                DecimalAttribute da = ep.DecimalAttribute;
                if (da == null) throw new Exception( "DecimalAttribute not found=" + entity.FullName + "_" + ep.Name );

                sb.Append( columnName );
                sb.Append( " decimal(" + da.Precision + "," + da.Scale + ") default 0, " );
            }
        }
開發者ID:2014AmethystCat,項目名稱:wojilu,代碼行數:14,代碼來源:AccessTableBuilder.cs

示例7: setEntityPropertyValueById

 private static void setEntityPropertyValueById( IEntity obj, ObjectInfo state, EntityPropertyInfo property, int pid )
 {
     if (!property.IsAbstractEntity) {
         IEntity objValue = Entity.New( property.Type.FullName );
         objValue.Id = pid;
         // state
         //objValue.state = new ObjectInfo( property.Type ).Copy( state );
         IEntity objCache = ObjectPool.FindOne( property.Type, objValue.Id );
         if (objCache != null) {
             objValue = objCache;
         }
         obj.set( property.Name, objValue );
     }
 }
開發者ID:robin88,項目名稱:wojilu,代碼行數:14,代碼來源:FillUtil.cs

示例8: isContinue

        private static Boolean isContinue( String action, EntityPropertyInfo info, EntityInfo entityInfo )
        {
            if (info.SaveToDB == false) return true;
            if (info.IsList) return true;

            if (info.Name.Equals( "Id" )) {

                if (action.Equals( "update" )) return true;
                if (action.Equals( "insert" ) && entityInfo.Parent == null) return true;

            }

            return false;
        }
開發者ID:LeoLcy,項目名稱:cnblogsbywojilu,代碼行數:14,代碼來源:OrmUtil.cs

示例9: Validate

        public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
        {
            if (!Regex.IsMatch( cvt.ToNotNull( target.get( info.Name ) ), this.Regexp, RegexOptions.Singleline )) {
                if (strUtil.HasText( this.Message )) {
                    result.Add( this.Message );
                }

                else {
                    EntityInfo ei = Entity.GetInfo( target );
                    String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
                    result.Add( str + " is not match the format pattern : " + this.Regexp );
                }

            }
        }
開發者ID:991899783,項目名稱:BookShop,代碼行數:15,代碼來源:PatternAttribute.cs

示例10: Validate

        public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
        {
            Object obj = target.get( info.Name );

            EntityInfo ei = Entity.GetInfo( target );
            int count = getCount( action, target, ei, info, obj );

            if (count > 0) {
                if (strUtil.HasText( this.Message )) {
                    result.Add( this.Message );
                }

                else {
                    String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
                    result.Add( str + " should be unique, but it has been in database" );
                }
            }
        }
開發者ID:2014AmethystCat,項目名稱:wojilu,代碼行數:18,代碼來源:UniqueAttribute.cs

示例11: getCount

        private static int getCount( String action, IEntity target, EntityInfo entityInfo, EntityPropertyInfo info, Object obj )
        {
            if (obj == null) return 1;

            String usql;
            IDatabaseDialect dialect = entityInfo.Dialect;
            if (action.Equals( "update" )) {
                usql = String.Format( "select count(Id) from {0} where Id<>{3} and {1}={2}", entityInfo.TableName, info.ColumnName, dialect.GetParameter( info.Name ), target.Id );
            }
            else {
                usql = String.Format( "select count(Id) from {0} where {1}={2}", entityInfo.TableName, info.ColumnName, dialect.GetParameter( info.Name ) );
            }

            logger.Info( LoggerUtil.SqlPrefix + " validate unique sql : " + usql );
            IDbCommand cmd = DataFactory.GetCommand( usql, DbContext.getConnection( entityInfo ) );
            DataFactory.SetParameter( cmd, info.ColumnName, obj );
            return cvt.ToInt( cmd.ExecuteScalar() );
        }
開發者ID:2014AmethystCat,項目名稱:wojilu,代碼行數:18,代碼來源:UniqueAttribute.cs

示例12: isContinue

        private static Boolean isContinue( String action, EntityPropertyInfo info, EntityInfo entityInfo )
        {
            if (info.SaveToDB == false) return true;
            if (info.IsList) return true;

            if (info.Name.Equals( "Id" )) {

                if (action.Equals( "update" )) return true;

                // ����ʵ�������ʶ��
                if (/**/DbConfig.Instance.IsAutoId && action.Equals("insert")
                    && entityInfo.Parent == null
                    )
                    return true;
            }

            return false;
        }
開發者ID:991899783,項目名稱:BookShop,代碼行數:18,代碼來源:OrmUtil.cs

示例13: AddPropertyToHashtable

 internal void AddPropertyToHashtable( EntityPropertyInfo p )
 {
     _propertyHashTable[p.Name] = p;
     if (strUtil.HasText( p.ColumnName )) {
         _propertyHashTableByColumn[p.ColumnName.ToLower()] = p;
     }
 }
開發者ID:hzc13,項目名稱:wojilu,代碼行數:7,代碼來源:EntityInfo.cs

示例14: getEntityPropertyName

        private string getEntityPropertyName( EntityPropertyInfo ep, object propertyValue ) {

            IEntity pValue = propertyValue as IEntity;
            if (pValue == null) return "";

            string val = null;

            EntityInfo ei = Entity.GetInfo( pValue );

            if ((ei.GetProperty( "Name" ) != null) && (pValue.get( "Name" ) != null)) {
                val = pValue.get( "Name" ).ToString();
            }
            else if ((ei.GetProperty( "Title" ) != null) && (pValue.get( "Title" ) != null)) {
                val = pValue.get( "Title" ).ToString();
            }

            if (strUtil.HasText( val )) {
                String lnk = to( Model ) + "?typeName=" + ep.ParentEntityInfo.FullName + "&p=" + ep.Name + "&id=" + pValue.Id;
                return "<a title=\"" + ep.Type.FullName + ", Id=" + pValue.Id + "\" href=\"" + lnk + "\">" + val + "</a>";
            }
            else {
                return ep.Type.Name + "_" + pValue.Id;
            }
        }
開發者ID:jasonvip,項目名稱:wojilu.CodeGenerator,代碼行數:24,代碼來源:CodeController.cs

示例15: getPropertyValue

 private string getPropertyValue( IEntity obj, EntityPropertyInfo ep ) {
     object val = obj.get( ep.Name );
     if (val == null) {
         return "";
     }
     return val.ToString();
 }
開發者ID:jasonvip,項目名稱:wojilu.CodeGenerator,代碼行數:7,代碼來源:CodeController.cs


注:本文中的wojilu.ORM.EntityPropertyInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。