本文整理汇总了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;
}
示例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;
}