当前位置: 首页>>代码示例>>C#>>正文


C# IObjectInfo类代码示例

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


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

示例1: BuildDeleteSqlQuery

        /// <summary>
        /// Builds an SqlQuery to delete the database record with the specified identifier for the type specified by the IObjectInfo.
        /// </summary>
        /// <param name="objectInfo">The object information.</param>
        /// <param name="identifier">The identifier of the instance to delete.</param>
        /// <returns>
        /// The created <see cref="SqlQuery" />.
        /// </returns>
        public SqlQuery BuildDeleteSqlQuery(IObjectInfo objectInfo, object identifier)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            string deleteCommand;

            if (!this.deleteCommandCache.TryGetValue(objectInfo.ForType, out deleteCommand))
            {
                var deleteSqlQuery = new DeleteSqlBuilder(this.SqlCharacters)
                    .From(objectInfo)
                    .WhereEquals(objectInfo.TableInfo.IdentifierColumn.ColumnName, identifier)
                    .ToSqlQuery();

                var newDeleteCommandCache = new Dictionary<Type, string>(this.deleteCommandCache);
                newDeleteCommandCache[objectInfo.ForType] = deleteSqlQuery.CommandText;

                this.deleteCommandCache = newDeleteCommandCache;

                return deleteSqlQuery;
            }

            return new SqlQuery(deleteCommand, identifier);
        }
开发者ID:rubenalves,项目名称:MicroLite,代码行数:34,代码来源:SqlDialect.cs

示例2: CreateGetIdentifier

        internal static Func<object, object> CreateGetIdentifier(IObjectInfo objectInfo)
        {
            var dynamicMethod = new DynamicMethod(
                name: "MicroLite" + objectInfo.ForType.Name + "GetIdentifier",
                returnType: typeof(object),
                parameterTypes: new[] { typeof(object) }); // arg_0

            var ilGenerator = dynamicMethod.GetILGenerator();

            // var instance = ({Type})arg_0;
            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Castclass, objectInfo.ForType);

            // var identifier = instance.Id;
            ilGenerator.Emit(OpCodes.Callvirt, objectInfo.TableInfo.IdentifierColumn.PropertyInfo.GetGetMethod());

            // value = (object)identifier;
            ilGenerator.EmitBoxIfValueType(objectInfo.TableInfo.IdentifierColumn.PropertyInfo.PropertyType);

            // return identifier;
            ilGenerator.Emit(OpCodes.Ret);

            var getIdentifierValue = (Func<object, object>)dynamicMethod.CreateDelegate(typeof(Func<object, object>));

            return getIdentifierValue;
        }
开发者ID:TrevorPilley,项目名称:MicroLite,代码行数:26,代码来源:DelegateFactory.cs

示例3: BuildInsertCommandText

        protected override string BuildInsertCommandText(IObjectInfo objectInfo)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            var commandText = base.BuildInsertCommandText(objectInfo);

            if (objectInfo.TableInfo.IdentifierStrategy == IdentifierStrategy.Sequence)
            {
                var firstParenthesisIndex = commandText.IndexOf('(') + 1;

                commandText = commandText.Insert(
                    firstParenthesisIndex,
                    this.SqlCharacters.EscapeSql(objectInfo.TableInfo.IdentifierColumn.ColumnName) + ",");

                var secondParenthesisIndex = commandText.IndexOf('(', firstParenthesisIndex) + 1;

                commandText = commandText.Insert(
                    secondParenthesisIndex,
                    "GEN_ID(" + objectInfo.TableInfo.IdentifierColumn.SequenceName + ", 1),");
            }

            if (objectInfo.TableInfo.IdentifierStrategy != IdentifierStrategy.Assigned)
            {
                commandText += " RETURNING " + objectInfo.TableInfo.IdentifierColumn.ColumnName;
            }

            return commandText;
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:31,代码来源:FirebirdSqlDialect.cs

示例4: From

        internal IWhere From(IObjectInfo objectInfo)
        {
            this.InnerSql.Append(" FROM ");
            this.AppendTableName(objectInfo);

            return this;
        }
开发者ID:TrevorPilley,项目名称:MicroLite,代码行数:7,代码来源:DeleteSqlBuilder.cs

示例5: Table

        internal ISetOrWhere Table(IObjectInfo objectInfo)
        {
            this.AppendTableName(objectInfo);
            this.InnerSql.Append(" SET ");

            return this;
        }
开发者ID:TrevorPilley,项目名称:MicroLite,代码行数:7,代码来源:UpdateSqlBuilder.cs

示例6: CreateGetInsertValues

        internal static Func<object, SqlArgument[]> CreateGetInsertValues(IObjectInfo objectInfo)
        {
            var dynamicMethod = new DynamicMethod(
                name: "MicroLite" + objectInfo.ForType.Name + "GetInsertValues",
                returnType: typeof(SqlArgument[]),
                parameterTypes: new[] { typeof(object) }, // arg_0
                m: typeof(ObjectInfo).Module);

            var ilGenerator = dynamicMethod.GetILGenerator();

            ilGenerator.DeclareLocal(objectInfo.ForType);     // loc_0 - {Type} instance;
            ilGenerator.DeclareLocal(typeof(SqlArgument[]));  // loc_1 - SqlArgument[] sqlArguments;

            // instance = ({Type})arg_0;
            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Castclass, objectInfo.ForType);
            ilGenerator.Emit(OpCodes.Stloc_0);

            // sqlArguments = new SqlArgument[count];
            ilGenerator.EmitEfficientInt(objectInfo.TableInfo.InsertColumnCount);
            ilGenerator.Emit(OpCodes.Newarr, typeof(SqlArgument));
            ilGenerator.Emit(OpCodes.Stloc_1);

            EmitGetPropertyValues(ilGenerator, objectInfo, c => c.AllowInsert);

            // return sqlArguments;
            ilGenerator.Emit(OpCodes.Ldloc_1);
            ilGenerator.Emit(OpCodes.Ret);

            var getInsertValues = (Func<object, SqlArgument[]>)dynamicMethod.CreateDelegate(typeof(Func<object, SqlArgument[]>));

            return getInsertValues;
        }
开发者ID:TrevorPilley,项目名称:MicroLite,代码行数:33,代码来源:DelegateFactory.cs

示例7: BuildInsertCommandText

        protected override string BuildInsertCommandText(IObjectInfo objectInfo)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            var commandText = base.BuildInsertCommandText(objectInfo);

            if (objectInfo.TableInfo.IdentifierStrategy == IdentifierStrategy.Sequence)
            {
                commandText = "DECLARE @@id " + GetSqlType(objectInfo.TableInfo.IdentifierColumn) + ";"
                    + "SELECT @@id = NEXT VALUE FOR " + objectInfo.TableInfo.IdentifierColumn.SequenceName + ";"
                    + commandText;

                var firstParenthesisIndex = commandText.IndexOf('(') + 1;

                commandText = commandText.Insert(
                    firstParenthesisIndex,
                    this.SqlCharacters.EscapeSql(objectInfo.TableInfo.IdentifierColumn.ColumnName) + ",");

                var secondParenthesisIndex = commandText.IndexOf('(', firstParenthesisIndex) + 1;

                commandText = commandText.Insert(
                    secondParenthesisIndex,
                    "@@id,");
            }

            return commandText;
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:30,代码来源:MsSql2012Dialect.cs

示例8: BindSelect

        /// <summary>
        /// Binds the select query option to the SqlBuilder.
        /// </summary>
        /// <param name="selectQueryOption">The select query option.</param>
        /// <param name="objectInfo">The IObjectInfo for the type to bind the select list for.</param>
        /// <returns>The SqlBuilder after the select and from clauses have been added.</returns>
        public static IWhereOrOrderBy BindSelect(SelectQueryOption selectQueryOption, IObjectInfo objectInfo)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            if (selectQueryOption == null || (selectQueryOption.Properties.Count == 1 && selectQueryOption.Properties[0] == "*"))
            {
                return SqlBuilder.Select("*").From(objectInfo.ForType);
            }

            var columnNames = new string[selectQueryOption.Properties.Count];
            int columnCount = 0;

            for (int i = 0; i < selectQueryOption.Properties.Count; i++)
            {
                var property = selectQueryOption.Properties[i];
                var column = objectInfo.TableInfo.GetColumnInfoForProperty(property);

                if (column == null)
                {
                    throw new ODataException(string.Format(CultureInfo.InvariantCulture, Messages.InvalidPropertyName, objectInfo.ForType.Name, property));
                }

                columnNames[columnCount++] = column.ColumnName;
            }

            return SqlBuilder.Select(columnNames).From(objectInfo.ForType);
        }
开发者ID:TrevorPilley,项目名称:MicroLite.Extensions.WebApi,代码行数:36,代码来源:SelectBinder.cs

示例9: ArgumentException

        void IObjectManager.CreateObject(IObjectInfo objInfo)
        {
            var variableInfo = objInfo as VariableInfo;
            if (variableInfo == null)
                throw new ArgumentException();

            DefineVariable(variableInfo);
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:8,代码来源:PersistentVariableManager.cs

示例10: Encode

			public void Encode(ByteArrayOutputStream os, IObjectInfo info)
			{
				PrimitiveCodec.WriteLong(os, info.GetInternalID());
				long sourceDatabaseId = ((FrozenObjectInfo)info).SourceDatabaseId(this._enclosing
					.Transaction());
				PrimitiveCodec.WriteLong(os, sourceDatabaseId);
				PrimitiveCodec.WriteLong(os, ((FrozenObjectInfo)info).UuidLongPart());
				PrimitiveCodec.WriteLong(os, info.GetCommitTimestamp());
			}
开发者ID:erdincay,项目名称:db4o,代码行数:9,代码来源:MCommittedInfo.cs

示例11: AssertInfosAreConsistent

 private void AssertInfosAreConsistent(long[] ids, IObjectInfo[] infos)
 {
     for (var i = 0; i < infos.Length; i++)
     {
         var info = Db().GetObjectInfo(Db().GetByID(ids[i]));
         Assert.AreEqual(info.GetInternalID(), infos[i].GetInternalID());
         Assert.AreEqual(info.GetUUID().GetLongPart(), infos[i].GetUUID().GetLongPart());
         Assert.AreSame(info.GetObject(), infos[i].GetObject());
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:10,代码来源:LazyObjectReferenceTestCase.cs

示例12: AlterObject

        public static void AlterObject(this IQueryContext context, IObjectInfo objectInfo)
        {
            if (objectInfo == null)
                throw new ArgumentNullException("objectInfo");

            if (!context.UserCanAlterObject(objectInfo.ObjectType, objectInfo.FullName))
                throw new MissingPrivilegesException(context.UserName(), objectInfo.FullName, Privileges.Alter);

            context.Session().AlterObject(objectInfo);
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:10,代码来源:QueryContext.Objects.cs

示例13: BuildInsertCommandText

        protected override string BuildInsertCommandText(IObjectInfo objectInfo)
        {
            var commandText = base.BuildInsertCommandText(objectInfo);

            if (objectInfo.TableInfo.IdentifierStrategy == IdentifierStrategy.DbGenerated)
            {
                commandText += " RETURNING " + objectInfo.TableInfo.IdentifierColumn.ColumnName;
            }

            return commandText;
        }
开发者ID:rubenalves,项目名称:MicroLite,代码行数:11,代码来源:FirebirdSqlDialect.cs

示例14: AppendTableName

        /// <summary>
        /// Appends the table name to the inner sql.
        /// </summary>
        /// <param name="objectInfo">The object information.</param>
        protected void AppendTableName(IObjectInfo objectInfo)
        {
            if (!string.IsNullOrEmpty(objectInfo.TableInfo.Schema))
            {
                this.InnerSql.Append(this.sqlCharacters.LeftDelimiter)
                    .Append(objectInfo.TableInfo.Schema)
                    .Append(this.sqlCharacters.RightDelimiter)
                    .Append('.');
            }

            this.AppendTableName(objectInfo.TableInfo.Name);
        }
开发者ID:rubenalves,项目名称:MicroLite,代码行数:16,代码来源:SqlBuilderBase.cs

示例15: AssertGeneration

			private void AssertGeneration(IObjectInfo objectInfo, bool expectGeneration)
			{
				if (expectGeneration)
				{
					Assert.IsNotNull(objectInfo.GetUUID());
				}
				else
				{
					Assert.IsNull(objectInfo.GetUUID());
					Assert.AreEqual(0L, objectInfo.GetCommitTimestamp());
				}
			}
开发者ID:superyfwy,项目名称:db4o,代码行数:12,代码来源:ClassConfigOverridesGlobalConfigTestSuite.cs


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