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


C# EntityMetadata.GetFullSequenceName方法代码示例

本文整理汇总了C#中EntityMetadata.GetFullSequenceName方法的典型用法代码示例。如果您正苦于以下问题:C# EntityMetadata.GetFullSequenceName方法的具体用法?C# EntityMetadata.GetFullSequenceName怎么用?C# EntityMetadata.GetFullSequenceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityMetadata的用法示例。


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

示例1: GenerateInsertCommandWithAutogeneratedField

        protected override DbCommand GenerateInsertCommandWithAutogeneratedField(CommandBuilder commandBuilder, object entity, EntityMetadata entityMetadata)
        {
            if (!string.IsNullOrEmpty(entityMetadata.AutoIncrementFieldName)) return base.GenerateInsertCommandWithAutogeneratedField(commandBuilder, entity, entityMetadata);
            if (string.IsNullOrEmpty(entityMetadata.SequenceFieldName)) throw new InvalidOperationException(entity.GetType().Name + " has no autogenerated field");

            var cmd = commandBuilder.DataService.DbProviderFactory.CreateCommand();
            StringBuilder commandText = new StringBuilder();
            commandText.Append(string.Format("DECLARE {0} bigint = NEXT VALUE FOR {1};", SequenceVariable, entityMetadata.GetFullSequenceName(this.DefaultSchema)));
            commandBuilder.AppendInsertStatement(entity, cmd, commandText);
            commandText.Append(string.Format(";\nSELECT {0} AS AutogeneratedField;", SequenceVariable));
            cmd.CommandText = commandText.ToString();
            return cmd;
        }
开发者ID:jesuslpm,项目名称:EntityLite,代码行数:13,代码来源:SqlServerEntityLiteProvider.cs

示例2: GenerateInsertCommandWithAutogeneratedField

 protected override DbCommand GenerateInsertCommandWithAutogeneratedField(CommandBuilder commandBuilder, object entity, EntityMetadata entityMetadata)
 {
     var cmd = commandBuilder.DataService.DbProviderFactory.CreateCommand();
     StringBuilder commandText = new StringBuilder();
     commandText.Append(string.Format(@"
     DECLARE
     {0} NUMERIC(18);
     BEGIN
     {0} := {1}.nextval;", SequenceVariable, entityMetadata.GetFullSequenceName(commandBuilder.DataService.EntityLiteProvider.DefaultSchema)));
     commandBuilder.AppendInsertStatement(entity, cmd, commandText);
     commandText.Append(string.Format(@";
     :id_seq_$param$ := {0};
     END;", SequenceVariable));
     IDbDataParameter idp = cmd.CreateParameter();
     idp.ParameterName = ":id_seq_$param$";
     idp.Direction = ParameterDirection.Output;
     idp.DbType = DbType.Int64;
     cmd.Parameters.Add(idp);
     cmd.CommandText = commandText.ToString();
     return cmd;
 }
开发者ID:jesuslpm,项目名称:EntityLite,代码行数:21,代码来源:OracleEntityLiteProvider.cs


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