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

C# IObjectInfo类代码示例

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

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



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


示例16: AlterObject

        public static bool AlterObject(this ITransaction transaction, IObjectInfo objInfo)
        {
            if (objInfo == null)
                throw new ArgumentNullException("objInfo");

            var manager = transaction.GetObjectManager(objInfo.ObjectType);
            if (manager == null)
                throw new InvalidOperationException();

            if (manager.ObjectType != objInfo.ObjectType)
                throw new ArgumentException();

            return manager.AlterObject(objInfo);
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:14,代码来源:TransactionExtensions.cs


示例17: BuildSelectInsertIdSqlQuery

        public override SqlQuery BuildSelectInsertIdSqlQuery(IObjectInfo objectInfo)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            if (objectInfo.TableInfo.IdentifierStrategy == IdentifierStrategy.Sequence)
            {
                return new SqlQuery("SELECT @@id");
            }

            return base.BuildSelectInsertIdSqlQuery(objectInfo);
        }
开发者ID:natarajanmca11,项目名称:MicroLite,代码行数:14,代码来源:MsSql2012Dialect.cs


示例18: CreateObject

        public static void CreateObject(this ITransaction transaction, IObjectInfo objInfo)
        {
            if (objInfo == null)
                throw new ArgumentNullException("objInfo");

            var manager = transaction.GetObjectManager(objInfo.ObjectType);
            if (manager == null)
                throw new InvalidOperationException(String.Format("Could not find any manager for object type '{0}' configured for the system.", objInfo.ObjectType));

            if (manager.ObjectType != objInfo.ObjectType)
                throw new ArgumentException(
                    String.Format("Could not create an object of type '{0}' with the manager '{1}' (supported '{2}' type)",
                        objInfo.ObjectType, manager.GetType().FullName, manager.ObjectType));

            manager.CreateObject(objInfo);
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:16,代码来源:TransactionExtensions.cs


示例19: Db4oReplicationReferenceImpl

		internal Db4oReplicationReferenceImpl(IObjectInfo objectInfo)
		{
			ObjectReference yo = (ObjectReference)objectInfo;
			Transaction trans = yo.Transaction();
			Db4objects.Db4o.Internal.VirtualAttributes va = yo.VirtualAttributes(trans);
			if (va != null)
			{
				SetVirtualAttributes((Db4objects.Db4o.Internal.VirtualAttributes)va.ShallowClone(
					));
			}
			else
			{
				// No virtu
				SetVirtualAttributes(new Db4objects.Db4o.Internal.VirtualAttributes());
			}
			object obj = yo.GetObject();
			SetObject(obj);
			Ref_init();
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:19,代码来源:Db4oReplicationReferenceImpl.cs


示例20: AlterObject

        public override bool AlterObject(IObjectInfo objectInfo)
        {
            if (objectInfo == null)
                throw new ArgumentNullException("objectInfo");

            if (objectInfo.ObjectType == DbObjectType.Cursor ||
                objectInfo.ObjectType == DbObjectType.Variable) {
                throw new NotSupportedException();
            }

            if (objectInfo.ObjectType == DbObjectType.Table) {
                return AlterTable((TableInfo) objectInfo);
            }

            if (objectInfo.ObjectType == DbObjectType.Trigger &&
                Request.Context.TriggerExists(objectInfo.FullName.Name)) {
                // TODO:
            }

            return base.AlterObject(objectInfo);
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:21,代码来源:RequestAccess.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IObjectSource类代码示例发布时间:2022-05-24
下一篇:
C# IObjectFactory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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