• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ORM.EntityInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中wojilu.ORM.EntityInfo的典型用法代码示例。如果您正苦于以下问题:C# EntityInfo类的具体用法?C# EntityInfo怎么用?C# EntityInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EntityInfo类属于wojilu.ORM命名空间,在下文中一共展示了EntityInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetParameters

        internal static void SetParameters( IDbCommand cmd, String action, IEntity obj, EntityInfo entityInfo )
        {
            for (int i = 0; i < entityInfo.SavedPropertyList.Count; i++) {

                EntityPropertyInfo info = entityInfo.SavedPropertyList[i];

                if (isContinue( action, info, entityInfo )) continue;

                Object paramVal = obj.get( info.Name );
                if (paramVal == null && info.DefaultAttribute != null) {
                    paramVal = info.DefaultAttribute.Value;
                }

                if (paramVal == null) {
                    setDefaultValue( cmd, info, entityInfo );
                }
                else if (info.Type.IsSubclassOf( typeof( IEntity ) ) || MappingClass.Instance.ClassList.Contains( info.Type.FullName )) {
                    setEntityId( cmd, info, paramVal );
                }
                else {
                    paramVal = DataFactory.SetParameter( cmd, info.ColumnName, paramVal );
                    obj.set( info.Name, paramVal );
                }

            }
        }
开发者ID:991899783,项目名称:BookShop,代码行数:26,代码来源:OrmUtil.cs


示例2: 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


示例3: getConnection

        /// <summary>
        /// 获取数据库连接,返回的连接已经打开(open);在 mvc 框架中不用关闭,框架会自动关闭连接。
        /// 之所以要传入 EntityInfo,因为 ORM 支持多个数据库,不同的类型有可能映射到不同的数据库。
        /// </summary>
        /// <param name="et"></param>
        /// <returns></returns>
        public static IDbConnection getConnection( EntityInfo et ) {

            String db = et.Database;
            String connectionString = DbConfig.GetConnectionString( db );

            IDbConnection connection;
            getConnectionAll().TryGetValue( db, out connection );

            if (connection == null) {
                connection = DataFactory.GetConnection( connectionString, et.DbType );

                connection.Open();
                setConnection( db, connection );

                if (shouldTransaction()) {
                    IDbTransaction trans = connection.BeginTransaction();
                    setTransaction( db, trans );
                }

                return connection;
            }
            if (connection.State == ConnectionState.Closed) {
                connection.ConnectionString = connectionString;
                connection.Open();
            }
            return connection;
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:33,代码来源:DbContext.cs


示例4: addColumn_PrimaryKey

 protected override void addColumn_PrimaryKey( EntityInfo entity, StringBuilder sb, Dictionary<String, EntityInfo> clsList ) {
     if (isAddIdentityKey( entity.Type ) == false) {
         sb.Append( " Id int primary key default 0, " );
     }
     else {
         sb.Append( " Id int identity(1,1) primary key, " );
     }
 }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:8,代码来源:AccessTableBuilder.cs


示例5: makeOneController

        private void makeOneController( EntityInfo ei ) {

            String[] arrTypeItem = ei.FullName.Split( '.' );

            String domainNamespace = strUtil.TrimEnd( ei.FullName, "." + arrTypeItem[arrTypeItem.Length - 1] );

            string codeList = this.getListCode( ei );
            string codeAdd = this.getAddCode( ei );
            string codeCreate = this.getCreateCode( ei );
            string codeEdit = this.getEditCode( ei );
            string codeUpdate = this.getUpdateCode( ei );
            string codeDel = this.getDeleteCode( ei );

            Template template = new Template();
            template.InitContent( CrudActionTemplate.GetController() );

            template.Set( "domainNamespace", domainNamespace );
            template.Set( "namespace", this.namespaceName );
            template.Set( "controllerName", ei.Name );

            template.Set( "domainCamelName", strUtil.GetCamelCase( ei.Name ) );

            IBlock setList = template.GetBlock( "setList" );
            foreach (EntityPropertyInfo ep in ei.SavedPropertyList) {

                setList.Set( "propertyName", ep.Name );

                if (ep.IsLongText) {

                    if (rft.GetAttribute( ep.Property, typeof( HtmlTextAttribute ) ) == null) {
                        setList.Set( "propertyValue", "strUtil.CutString( data." + ep.Name + ", 30 )" );
                    }
                    else {
                        setList.Set( "propertyValue", "strUtil.ParseHtml( data." + ep.Name + ", 50 )" );
                    }
                }
                else if (ep.IsEntity) {

                    String entityName = getEntityName( ep );
                    setList.Set( "propertyValue", "data." + entityName );
                }
                else {
                    setList.Set( "propertyValue", "data." + ep.Name );
                }

                setList.Next();
            }

            template.Set( "listCode", codeList );
            template.Set( "addCode", codeAdd );
            template.Set( "createCode", codeCreate );
            template.Set( "editCode", codeEdit );
            template.Set( "updateCode", codeUpdate );
            template.Set( "deleteCode", codeDel );

            wojilu.IO.File.Write( Path.Combine( this.controllerPath, string.Format( "{0}Controller.cs", ei.Name ) ), template.ToString() );
        }
开发者ID:OnPeaceOfMind,项目名称:wojilu.CodeGenerator,代码行数:57,代码来源:CodeService.cs


示例6: addColumns

 private void addColumns( EntityInfo entity, StringBuilder sb ) {
     for (int i = 0; i < entity.SavedPropertyList.Count; i++) {
         EntityPropertyInfo ep = entity.SavedPropertyList[i];
         String columnName = getFullName( ep.ColumnName, entity );
         if ((ep.SaveToDB && !ep.IsList) && !(ep.Name == "Id")) {
             addColumnSingle( entity, sb, ep, columnName );
         }
     }
 }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:9,代码来源:TableBuilderBase.cs


示例7: 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


示例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: 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


示例10: 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


示例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: CheckCountCache

 public static void CheckCountCache( String action, IEntity obj, EntityInfo entityInfo )
 {
     for (int i = 0; i < entityInfo.SavedPropertyList.Count; i++) {
         IEntity container = null;
         String propertyName = null;
         EntityPropertyInfo info = entityInfo.SavedPropertyList[i];
         if ((info.Name != "Id") && !(info.Name == "OID")) {
             ICacheAttribute attribute = ReflectionUtil.GetAttribute( info.Property, typeof( CacheCountAttribute ) ) as ICacheAttribute;
             if (attribute != null) {
                 container = ReflectionUtil.GetPropertyValue( obj, info.Name ) as IEntity;
                 propertyName = attribute.TargetPropertyName.Replace( " ", "" );
             }
             if (container != null) {
                 String columnName = Entity.GetInfo( container ).GetColumnName( propertyName );
                 setCountCacheBySql( container, columnName, action );
             }
         }
     }
 }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:19,代码来源:CacheUtil.cs


示例13: createTable

        private List<String> createTable( EntityInfo entity, IDbCommand cmd, List<String> existTables, Dictionary<String, EntityInfo> clsList ) {

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat( "Create Table {0} (", getFullName( entity.TableName, entity ) );
            addColumn_PrimaryKey( entity, sb, clsList );

            addColumns( entity, sb );
            String str = sb.ToString().Trim().TrimEnd( new char[] { ',' } ) + " )";

            cmd.CommandText = str;
            logger.Info( "create table:" + str );
            if (cmd.Connection == null) throw new Exception( "connection is null" );

            if (cmd.Connection.State == ConnectionState.Closed) {
                cmd.Connection.Open();
            }

            cmd.ExecuteNonQuery();

            existTables.Add( entity.TableName );
            logger.Info( LoggerUtil.SqlPrefix + String.Format( "create table {0} ({1})", entity.TableName, entity.FullName ) );

            return existTables;
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:24,代码来源:TableBuilderBase.cs


示例14: getPropertyValue

        private string getPropertyValue( IEntity data, EntityInfo ei, String propertyName )
        {
            if (ei.GetProperty( propertyName ) == null) return "";

            Object summary = data.get( propertyName );

            return summary == null ? "" : summary.ToString();
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:8,代码来源:TagController.cs


示例15: checkCustomMapping

        private static void checkCustomMapping( EntityInfo info )
        {
            Dictionary<String, MappingInfo> map = DbConfig.Instance.GetMappingInfo();
            if (map.ContainsKey( info.Type.FullName )) {

                MappingInfo mi = map[info.Type.FullName];

                if (strUtil.HasText( mi.table )) info.TableName = mi.table;
                if (strUtil.HasText( mi.database )) info.Database = mi.database;

            }
        }
开发者ID:hzc13,项目名称:wojilu,代码行数:12,代码来源:EntityInfo.cs


示例16: addColumn_Double

 protected virtual void addColumn_Double( EntityInfo entity, StringBuilder sb, string columnName )
 {
     sb.Append( columnName );
     sb.Append( " float default 0, " );
 }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:5,代码来源:TableBuilderBase.cs


示例17: GetByType

        /// <summary>
        /// 根据类型Type,初始化EntityInfo;注意:因为不是从缓存中取,所以速度较慢
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        internal static EntityInfo GetByType( Type t )
        {
            EntityInfo info = new EntityInfo();

            info.Type = t;
            info.Name = t.Name;
            info.FullName = t.FullName;

            info.TableName = addPrefixToTableName( GetTableName( t ) );
            info.Database = getDatabase( t );

            checkCustomMapping( info );

            info.Label = getTypeLabel( t );

            IList propertyList = ReflectionUtil.GetPropertyList( t );
            for (int i = 0; i < propertyList.Count; i++) {
                PropertyInfo property = propertyList[i] as PropertyInfo;
                EntityPropertyInfo ep = EntityPropertyInfo.Get( property );
                ep.ParentEntityInfo = info;

                if (!(!ep.SaveToDB || ep.IsList)) {
                    info.SavedPropertyList.Add( ep );
                }
                info.PropertyListAll.Add( ep );
            }

            if (info.SavedPropertyList.Count == 1) {
                throw new Exception( "class's properties have not been setted '[save]' attribute." );
            }

            return info;
        }
开发者ID:hzc13,项目名称:wojilu,代码行数:38,代码来源:EntityInfo.cs


示例18: isTableCreated

 private Boolean isTableCreated( IList existTables, EntityInfo entity )
 {
     for (int i = 0; i < existTables.Count; i++) {
         if (string.Compare( existTables[i].ToString(), entity.TableName.Replace( "[", "" ).Replace( "]", "" ), true ) == 0) {
             logger.Info( "table map : " + entity.FullName + " => " + existTables[i] );
             return true;
         }
     }
     return false;
 }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:10,代码来源:TableBuilderBase.cs


示例19: SqlBuilder

 public SqlBuilder(EntityInfo entityInfo)
 {
     _entityInfo = entityInfo;
     _propertyList = _entityInfo.SavedPropertyList;
 }
开发者ID:jmyd,项目名称:oms,代码行数:5,代码来源:SqlBuilder.cs


示例20: getFullName

 //------------------------------------------------------------------------------------------------------------------------
 private String getFullName( String name, EntityInfo entity )
 {
     if (DbConst.SqlKeyWords.Contains( name.ToLower() )) {
         String message = String.Format( "'{0}'  is reserved word. Entity:{1}, Table:{2}", name, entity.FullName, entity.TableName );
         logger.Info( message );
         throw new Exception( message );
     }
     return name;
 }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:10,代码来源:TableBuilderBase.cs



注:本文中的wojilu.ORM.EntityInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ORM.EntityPropertyInfo类代码示例发布时间:2022-05-26
下一篇:
C# Service.UserService类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap