本文整理汇总了C#中FirebirdSql.Data.Common.Descriptor类的典型用法代码示例。如果您正苦于以下问题:C# Descriptor类的具体用法?C# Descriptor怎么用?C# Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Descriptor类属于FirebirdSql.Data.Common命名空间,在下文中一共展示了Descriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MarshalManagedToNative
public static IntPtr MarshalManagedToNative(Charset charset, Descriptor descriptor)
{
// Set up XSQLDA structure
var xsqlda = new XSQLDA
{
version = descriptor.Version,
sqln = descriptor.Count,
sqld = descriptor.ActualCount
};
var xsqlvar = new XSQLVAR[descriptor.Count];
for (var i = 0; i < xsqlvar.Length; i++)
{
// Create a new XSQLVAR structure and fill it
xsqlvar[i] = new XSQLVAR
{
sqltype = descriptor[i].DataType,
sqlscale = descriptor[i].NumericScale,
sqlsubtype = descriptor[i].SubType,
sqllen = descriptor[i].Length
};
// Create a new pointer for the xsqlvar data
if (descriptor[i].HasDataType() && descriptor[i].DbDataType != DbDataType.Null)
{
var buffer = descriptor[i].DbValue.GetBytes();
xsqlvar[i].sqldata = Marshal.AllocHGlobal(buffer.Length);
Marshal.Copy(buffer, 0, xsqlvar[i].sqldata, buffer.Length);
}
else
{
xsqlvar[i].sqldata = Marshal.AllocHGlobal(0);
}
// Create a new pointer for the sqlind value
xsqlvar[i].sqlind = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(short)));
Marshal.WriteInt16(xsqlvar[i].sqlind, descriptor[i].NullFlag);
// Name
xsqlvar[i].sqlname = GetStringBuffer(charset, descriptor[i].Name);
xsqlvar[i].sqlname_length = (short)descriptor[i].Name.Length;
// Relation Name
xsqlvar[i].relname = GetStringBuffer(charset, descriptor[i].Relation);
xsqlvar[i].relname_length = (short)descriptor[i].Relation.Length;
// Owner name
xsqlvar[i].ownername = GetStringBuffer(charset, descriptor[i].Owner);
xsqlvar[i].ownername_length = (short)descriptor[i].Owner.Length;
// Alias name
xsqlvar[i].aliasname = GetStringBuffer(charset, descriptor[i].Alias);
xsqlvar[i].aliasname_length = (short)descriptor[i].Alias.Length;
}
return MarshalManagedToNative(xsqlda, xsqlvar);
}
开发者ID:mrgleba,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:59,代码来源:XsqldaMarshaler.cs
示例2: Describe
public override void Describe()
{
lock (_db)
{
// Clear the status vector
ClearStatusVector();
// Update structure
_fields = new Descriptor(_fields.ActualCount);
// Marshal structures to pointer
IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields);
int stmtHandle = _handle;
_db.FbClient.isc_dsql_describe(
_statusVector,
ref stmtHandle,
IscCodes.SQLDA_VERSION1,
sqlda);
// Marshal Pointer
Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);
// Free memory
XsqldaMarshaler.CleanUpNativeData(ref sqlda);
// Parse status vector
_db.ParseStatusVector(_statusVector);
// Update field descriptor
_fields = descriptor;
}
}
开发者ID:fishcodelib,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:35,代码来源:FesStatement.cs
示例3: BuildParameterDescriptor
private bool BuildParameterDescriptor(Descriptor descriptor, FbParameter parameter, int index)
{
if (!parameter.IsTypeSet)
{
return false;
}
FbDbType type = parameter.FbDbType;
Charset charset = this.connection.InnerConnection.Database.Charset;
// Check the parameter character set
if (parameter.Charset == FbCharset.Octets && !(parameter.InternalValue is byte[]))
{
throw new InvalidOperationException("Value for char octets fields should be a byte array");
}
else if (type == FbDbType.Guid)
{
charset = Charset.GetCharset("OCTETS");
}
else if (parameter.Charset != FbCharset.Default)
{
charset = Charset.GetCharset((int)parameter.Charset);
}
// Set parameter Data Type
descriptor[index].DataType = (short)TypeHelper.GetFbType((DbDataType)type, parameter.IsNullable);
// Set parameter Sub Type
switch (type)
{
case FbDbType.Binary:
descriptor[index].SubType = 0;
break;
case FbDbType.Text:
descriptor[index].SubType = 1;
break;
case FbDbType.Guid:
descriptor[index].SubType = (short)charset.Identifier;
break;
case FbDbType.Char:
case FbDbType.VarChar:
descriptor[index].SubType = (short)charset.Identifier;
if (charset.IsOctetsCharset)
{
descriptor[index].Length = (short)parameter.Size;
}
else if (parameter.HasSize)
{
short len = (short)(parameter.Size * charset.BytesPerCharacter);
descriptor[index].Length = len;
}
break;
}
// Set parameter length
if (descriptor[index].Length == 0)
{
descriptor[index].Length = TypeHelper.GetSize((DbDataType)type);
}
// Verify parameter
if (descriptor[index].SqlType == 0 || descriptor[index].Length == 0)
{
return false;
}
return true;
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:71,代码来源:FbCommand.cs
示例4: MarshalManagedToNative
public IntPtr MarshalManagedToNative(Charset charset, Descriptor descriptor)
{
// Set up XSQLDA structure
XSQLDA xsqlda = new XSQLDA();
xsqlda.version = descriptor.Version;
xsqlda.sqln = descriptor.Count;
xsqlda.sqld = descriptor.ActualCount;
XSQLVAR[] xsqlvar = new XSQLVAR[descriptor.Count];
for (int i = 0; i < xsqlvar.Length; i++)
{
// Create a new XSQLVAR structure and fill it
xsqlvar[i] = new XSQLVAR();
xsqlvar[i].sqltype = descriptor[i].DataType;
xsqlvar[i].sqlscale = descriptor[i].NumericScale;
xsqlvar[i].sqlsubtype = descriptor[i].SubType;
xsqlvar[i].sqllen = descriptor[i].Length;
// Create a new pointer for the xsqlvar data
byte[] buffer = descriptor[i].DbValue.GetBytes();
xsqlvar[i].sqldata = Marshal.AllocHGlobal(buffer.Length);
Marshal.Copy(buffer, 0, xsqlvar[i].sqldata, buffer.Length);
// Create a new pointer for the sqlind value
xsqlvar[i].sqlind = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int16)));
Marshal.WriteInt16(xsqlvar[i].sqlind, descriptor[i].NullFlag);
// Name
xsqlvar[i].sqlname = this.GetStringBuffer(charset, descriptor[i].Name);
xsqlvar[i].sqlname_length = (short)descriptor[i].Name.Length;
// Relation Name
xsqlvar[i].relname = this.GetStringBuffer(charset, descriptor[i].Relation);
xsqlvar[i].relname_length = (short)descriptor[i].Relation.Length;
// Owner name
xsqlvar[i].ownername = this.GetStringBuffer(charset, descriptor[i].Owner);
xsqlvar[i].ownername_length = (short)descriptor[i].Owner.Length;
// Alias name
xsqlvar[i].aliasname = this.GetStringBuffer(charset, descriptor[i].Alias);
xsqlvar[i].aliasname_length = (short)descriptor[i].Alias.Length;
}
return this.MarshalManagedToNative(xsqlda, xsqlvar);
}
开发者ID:robsoft,项目名称:FirebirdMonoDroidProvider,代码行数:49,代码来源:XsqldaMarshaler.cs
示例5: Clone
public object Clone()
{
Descriptor descriptor = new Descriptor(this.Count);
descriptor.Version = this.version;
for (int i = 0; i < descriptor.Count; i++)
{
descriptor[i].DataType = this.fields[i].DataType;
descriptor[i].NumericScale = this.fields[i].NumericScale;
descriptor[i].SubType = this.fields[i].SubType;
descriptor[i].Length = this.fields[i].Length;
descriptor[i].Value = this.fields[i].Value;
descriptor[i].NullFlag = this.fields[i].NullFlag;
descriptor[i].Name = this.fields[i].Name;
descriptor[i].Relation = this.fields[i].Relation;
descriptor[i].Owner = this.fields[i].Owner;
descriptor[i].Alias = this.fields[i].Alias;
}
return descriptor;
}
开发者ID:Outlivier,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:21,代码来源:Descriptor.cs
示例6: ParseSqlInfo
protected void ParseSqlInfo(byte[] info, byte[] items, ref Descriptor[] rowDescs)
{
this.ParseTruncSqlInfo(info, items, ref rowDescs);
}
开发者ID:cafee,项目名称:NETProvider,代码行数:4,代码来源:GdsStatement.cs
示例7: Write
public void Write(Descriptor descriptor)
{
for (int i = 0; i < descriptor.Count; i++)
{
this.Write(descriptor[i]);
}
}
开发者ID:antgraf,项目名称:Embedded-DB-.Net-Performance-Test,代码行数:7,代码来源:XdrStream.cs
示例8: ProcessPrepareResponse
protected void ProcessPrepareResponse(GenericResponse response)
{
Descriptor[] descriptors = new Descriptor[] { null, null };
this.ParseSqlInfo(response.Data, DescribeInfoAndBindInfoItems, ref descriptors);
this.fields = descriptors[0];
this.parameters = descriptors[1];
}
开发者ID:cafee,项目名称:NETProvider,代码行数:7,代码来源:GdsStatement.cs
示例9: DescribeParameters
public override void DescribeParameters()
{
lock (_db)
{
// Clear the status vector
ClearStatusVector();
// Marshal structures to pointer
_parameters = new Descriptor(1);
IntPtr sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _parameters);
int stmtHandle = _handle;
_db.FbClient.isc_dsql_describe_bind(
_statusVector,
ref stmtHandle,
IscCodes.SQLDA_VERSION1,
sqlda);
Descriptor descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);
// Parse status vector
_db.ParseStatusVector(_statusVector);
if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount)
{
short n = descriptor.ActualCount;
descriptor = new Descriptor(n);
// Fre memory
XsqldaMarshaler.CleanUpNativeData(ref sqlda);
// Marshal new structure
sqlda = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, descriptor);
_db.FbClient.isc_dsql_describe_bind(
_statusVector,
ref stmtHandle,
IscCodes.SQLDA_VERSION1,
sqlda);
descriptor = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, sqlda);
// Free memory
XsqldaMarshaler.CleanUpNativeData(ref sqlda);
// Parse status vector
_db.ParseStatusVector(_statusVector);
}
else
{
if (descriptor.ActualCount == 0)
{
descriptor = new Descriptor(0);
}
}
// Free memory
if (sqlda != IntPtr.Zero)
{
XsqldaMarshaler.CleanUpNativeData(ref sqlda);
}
// Update parameter descriptor
_parameters = descriptor;
}
}
开发者ID:fishcodelib,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:69,代码来源:FesStatement.cs
示例10: ParseTruncSqlInfo
protected void ParseTruncSqlInfo(byte[] info, byte[] items, ref Descriptor[] rowDescs)
{
int currentPosition = 0;
int currentDescriptorIndex = -1;
int currentItemIndex = 0;
while (info[currentPosition] != IscCodes.isc_info_end)
{
bool jumpOutOfInnerLoop = false;
byte item;
while ((item = info[currentPosition++]) != IscCodes.isc_info_sql_describe_end)
{
switch (item)
{
case IscCodes.isc_info_truncated:
currentItemIndex--;
List<byte> newItems = new List<byte>(items.Length);
int part = 0;
int chock = 0;
for (int i = 0; i < items.Length; i++)
{
if (items[i] == IscCodes.isc_info_sql_describe_end)
{
newItems.Insert(chock, IscCodes.isc_info_sql_sqlda_start);
newItems.Insert(chock + 1, 2);
short processedItems = (rowDescs[part] != null ? rowDescs[part].Count : (short)0);
newItems.Insert(chock + 2, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) & 255));
newItems.Insert(chock + 3, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) >> 8));
part++;
chock = i + 4 + 1;
}
newItems.Add(items[i]);
}
info = this.GetSqlInfo(newItems.ToArray(), info.Length);
currentPosition = 0;
currentDescriptorIndex = -1;
jumpOutOfInnerLoop = true;
break;
case IscCodes.isc_info_sql_select:
case IscCodes.isc_info_sql_bind:
currentDescriptorIndex++;
if (info[currentPosition] == IscCodes.isc_info_truncated)
break;
currentPosition++;
int len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
if (rowDescs[currentDescriptorIndex] == null)
{
int n = IscHelper.VaxInteger(info, currentPosition, len);
rowDescs[currentDescriptorIndex] = new Descriptor((short)n);
jumpOutOfInnerLoop = (n == 0);
}
currentPosition += len;
break;
case IscCodes.isc_info_sql_sqlda_seq:
len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
currentItemIndex = IscHelper.VaxInteger(info, currentPosition, len);
currentPosition += len;
break;
case IscCodes.isc_info_sql_type:
len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
rowDescs[currentDescriptorIndex][currentItemIndex - 1].DataType = (short)IscHelper.VaxInteger(info, currentPosition, len);
currentPosition += len;
break;
case IscCodes.isc_info_sql_sub_type:
len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
rowDescs[currentDescriptorIndex][currentItemIndex - 1].SubType = (short)IscHelper.VaxInteger(info, currentPosition, len);
currentPosition += len;
break;
case IscCodes.isc_info_sql_scale:
len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
rowDescs[currentDescriptorIndex][currentItemIndex - 1].NumericScale = (short)IscHelper.VaxInteger(info, currentPosition, len);
currentPosition += len;
break;
case IscCodes.isc_info_sql_length:
len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
rowDescs[currentDescriptorIndex][currentItemIndex - 1].Length = (short)IscHelper.VaxInteger(info, currentPosition, len);
currentPosition += len;
break;
case IscCodes.isc_info_sql_field:
len = IscHelper.VaxInteger(info, currentPosition, 2);
currentPosition += 2;
//.........这里部分代码省略.........
开发者ID:cafee,项目名称:NETProvider,代码行数:101,代码来源:GdsStatement.cs
示例11: FbCursor
public FbCursor(FbCommand command)
{
this.command = command;
this.fields = this.command.GetFieldsDescriptor();
}
开发者ID:cafee,项目名称:NETProvider,代码行数:5,代码来源:FbCursor.cs
示例12: Describe
public override void Describe()
{
lock (this.db)
{
// Update structure
this.fields = new Descriptor(this.fields.ActualCount);
// Marshal structures to pointer
XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;
IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields);
int[] statusVector = ExtConnection.GetNewStatusVector();
int stmtHandle = this.handle;
SafeNativeMethods.isc_dsql_describe(
statusVector,
ref stmtHandle,
IscCodes.SQLDA_VERSION1,
sqlda);
// Marshal Pointer
Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
// Free memory
marshaler.CleanUpNativeData(ref sqlda);
// Parse status vector
this.db.ParseStatusVector(statusVector);
// Update field descriptor
this.fields = descriptor;
}
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:34,代码来源:ExtStatement.cs
示例13: MarshalNativeToManaged
public static Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData, bool fetching)
{
// Obtain XSQLDA information
var xsqlda = (XSQLDA)Marshal.PtrToStructure(pNativeData, typeof(XSQLDA));
// Create a new Descriptor
var descriptor = new Descriptor(xsqlda.sqln) { ActualCount = xsqlda.sqld };
// Obtain XSQLVAR members information
var xsqlvar = new XSQLVAR();
for (var i = 0; i < xsqlda.sqln; i++)
{
var ptr = GetIntPtr(pNativeData, ComputeLength(i));
MarshalXSQLVARNativeToManaged(ptr, xsqlvar);
// Map XSQLVAR information to Descriptor
descriptor[i].DataType = xsqlvar.sqltype;
descriptor[i].NumericScale = xsqlvar.sqlscale;
descriptor[i].SubType = xsqlvar.sqlsubtype;
descriptor[i].Length = xsqlvar.sqllen;
// Decode sqlind value
descriptor[i].NullFlag = xsqlvar.sqlind == IntPtr.Zero
? (short)0
: Marshal.ReadInt16(xsqlvar.sqlind);
// Set value
if (fetching)
{
if (descriptor[i].NullFlag != -1)
{
descriptor[i].SetValue(GetBytes(xsqlvar));
}
}
descriptor[i].Name = GetString(charset, xsqlvar.sqlname, xsqlvar.sqlname_length);
descriptor[i].Relation = GetString(charset, xsqlvar.relname, xsqlvar.relname_length);
descriptor[i].Owner = GetString(charset, xsqlvar.ownername, xsqlvar.ownername_length);
descriptor[i].Alias = GetString(charset, xsqlvar.aliasname, xsqlvar.aliasname_length);
}
return descriptor;
}
开发者ID:mrgleba,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:43,代码来源:XsqldaMarshaler.cs
示例14: DescribeParameters
public override void DescribeParameters()
{
lock (this.db)
{
// Marshal structures to pointer
XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;
this.parameters = new Descriptor(1);
IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, parameters);
int[] statusVector = ExtConnection.GetNewStatusVector();
int stmtHandle = this.handle;
SafeNativeMethods.isc_dsql_describe_bind(
statusVector,
ref stmtHandle,
IscCodes.SQLDA_VERSION1,
sqlda);
Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
// Parse status vector
this.db.ParseStatusVector(statusVector);
if (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount)
{
short n = descriptor.ActualCount;
descriptor = new Descriptor(n);
// Fre memory
marshaler.CleanUpNativeData(ref sqlda);
// Marshal new structure
sqlda = marshaler.MarshalManagedToNative(this.db.Charset, descriptor);
SafeNativeMethods.isc_dsql_describe_bind(
statusVector,
ref stmtHandle,
IscCodes.SQLDA_VERSION1,
sqlda);
descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
// Free memory
marshaler.CleanUpNativeData(ref sqlda);
// Parse status vector
this.db.ParseStatusVector(statusVector);
}
else
{
if (descriptor.ActualCount == 0)
{
descriptor = new Descriptor(0);
}
}
// Free memory
if (sqlda != IntPtr.Zero)
{
marshaler.CleanUpNativeData(ref sqlda);
}
// Update parameter descriptor
this.parameters = descriptor;
}
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:68,代码来源:ExtStatement.cs
示例15: MarshalNativeToManaged
public Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData, bool fetching)
{
// Obtain XSQLDA information
XSQLDA xsqlda = new XSQLDA();
xsqlda = (XSQLDA)Marshal.PtrToStructure(pNativeData, typeof(XSQLDA));
// Create a new Descriptor
Descriptor descriptor = new Descriptor(xsqlda.sqln);
descriptor.ActualCount = xsqlda.sqld;
// Obtain XSQLVAR members information
XSQLVAR[] xsqlvar = new XSQLVAR[xsqlda.sqln];
for (int i = 0; i < xsqlvar.Length; i++)
{
IntPtr ptr = this.GetIntPtr(pNativeData, this.ComputeLength(i));
xsqlvar[i] = (XSQLVAR)Marshal.PtrToStructure(ptr, typeof(XSQLVAR));
// Map XSQLVAR information to Descriptor
descriptor[i].DataType = xsqlvar[i].sqltype;
descriptor[i].NumericScale = xsqlvar[i].sqlscale;
descriptor[i].SubType = xsqlvar[i].sqlsubtype;
descriptor[i].Length = xsqlvar[i].sqllen;
// Decode sqlind value
if (xsqlvar[i].sqlind == IntPtr.Zero)
{
descriptor[i].NullFlag = 0;
}
else
{
descriptor[i].NullFlag = Marshal.ReadInt16(xsqlvar[i].sqlind);
}
// Set value
if (fetching)
{
if (descriptor[i].NullFlag != -1)
{
descriptor[i].SetValue(this.GetBytes(xsqlvar[i]));
}
}
descriptor[i].Name = this.GetString(charset, xsqlvar[i].sqlname);
descriptor[i].Relation = this.GetString(charset, xsqlvar[i].relname);
descriptor[i].Owner = this.GetString(charset, xsqlvar[i].ownername);
descriptor[i].Alias = this.GetString(charset, xsqlvar[i].aliasname);
}
return descriptor;
}
开发者ID:robsoft,项目名称:FirebirdMonoDroidProvider,代码行数:52,代码来源:XsqldaMarshaler.cs
示例16: Fetch
public override DbValue[] Fetch()
{
DbValue[] row = null;
if (this.state == StatementState.Deallocated)
{
throw new InvalidOperationException("Statement is not correctly created.");
}
if (this.statementType != DbStatementType.Select &&
this.statementType != DbStatementType.SelectForUpdate)
{
return null;
}
lock (this.db)
{
if (!this.allRowsFetched)
{
// Get the XSQLDA Marshaler
XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;
// Reset actual field values
this.fields.ResetValues();
// Marshal structures to pointer
IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, fields);
// Creta a new status vector
int[] statusVector = ExtConnection.GetNewStatusVector();
// Statement handle to be passed to the fetch method
int stmtHandle = this.handle;
// Fetch data
int status = SafeNativeMethods.isc_dsql_fetch(statusVector, ref stmtHandle, IscCodes.SQLDA_VERSION1, sqlda);
// Obtain values
Descriptor rowDesc = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
if (this.fields.Count == rowDesc.Count)
{
// Try to preserve Array Handle information
for (int i = 0; i < this.fields.Count; i++)
{
if (this.fields[i].IsArray() && this.fields[i].ArrayHandle != null)
{
rowDesc[i].ArrayHandle = this.fields[i].ArrayHandle;
}
}
}
this.fields = rowDesc;
// Free memory
marshaler.CleanUpNativeData(ref sqlda);
// Parse status vector
this.db.ParseStatusVector(statusVector);
if (status == 100)
{
this.allRowsFetched = true;
}
else
{
// Set row values
row = new DbValue[this.fields.ActualCount];
for (int i = 0; i < row.Length; i++)
{
row[i] = new DbValue(this, this.fields[i]);
}
}
}
}
return row;
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:77,代码来源:ExtStatement.cs
示例17: BuildNamedParametersDescriptor
private Descriptor BuildNamedParametersDescriptor(short count)
{
Descriptor descriptor = new Descriptor(count);
int index = 0;
for (int i = 0; i < this.namedParameters.Count; i++)
{
if (this.Parameters.IndexOf(this.namedParameters[i]) == -1)
{
throw new FbException(String.Format("Must declare the variable '{0}'", this.namedParameters[i]));
}
FbParameter parameter = this.Parameters[this.namedParameters[i]];
if (parameter.Direction == ParameterDirection.Input ||
parameter.Direction == ParameterDirection.InputOutput)
{
if (!this.BuildParameterDescriptor(descriptor, parameter, index++))
{
return null;
}
}
}
return descriptor;
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:26,代码来源:FbCommand.cs
示例18: Prepare
public override void Prepare(string commandText)
{
// Clear data
this.ClearAll();
lock (this.db)
{
if (this.state == StatementState.Deallocated)
{
// Allocate statement
this.Allocate();
}
// Marshal structures to pointer
XsqldaMarshaler marshaler = XsqldaMarshaler.Instance;
// Setup fields structure
this.fields = new Descriptor(1);
IntPtr sqlda = marshaler.MarshalManagedToNative(this.db.Charset, this.fields);
int[] statusVector = ExtConnection.GetNewStatusVector();
int trHandle = this.transaction.Handle;
int stmtHandle = this.handle;
byte[] buffer = this.db.Charset.GetBytes(commandText);
SafeNativeMethods.isc_dsql_prepare(
statusVector,
ref trHandle,
ref stmtHandle,
(short)buffer.Length,
buffer,
this.db.Dialect,
sqlda);
// Marshal Pointer
Descriptor descriptor = marshaler.MarshalNativeToManaged(this.db.Charset, sqlda);
// Free memory
marshaler.CleanUpNativeData(ref sqlda);
// Parse status vector
this.db.ParseStatusVector(statusVector);
// Describe fields
this.fields = descriptor;
if (this.fields.ActualCount > 0 && this.fields.ActualCount != this.fields.Count)
{
this.Describe();
}
else
{
if (this.fields.ActualCount == 0)
{
this.fields = new Descriptor(0);
}
}
// Reset actual field values
this.fields.ResetValues();
// Get Statement type
this.statementType = this.GetStatementType();
// Update state
this.state = StatementState.Prepared;
}
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:69,代码来源:ExtStatement.cs
示例19: BuildPlaceHoldersDescriptor
private Descriptor BuildPlaceHoldersDescriptor(short count)
{
Descriptor descriptor = new Descriptor(count);
int index = 0;
for (int i = 0; i < this.Parameters.Count; i++)
{
FbParameter parameter = this.Parameters[i];
if (parameter.Direction == ParameterDirection.Input ||
parameter.Direction == ParameterDirection.InputOutput)
{
if (!this.BuildParameterDescriptor(descriptor, parameter, index++))
{
return null;
}
}
}
return descriptor;
}
开发者ID:kingpong,项目名称:NETProvider,代码行数:21,代码来源:FbCommand.cs
示例20: Fetch
public override DbValue[] Fetch()
{
DbValue[] row = null;
if (_state == StatementState.Deallocated)
{
throw new InvalidOperationException("Statement is not correctly created.");
}
if (_statementType != DbStatementType.Select &&
_statementType != DbStatementType.SelectForUpdate)
{
return null;
}
lock (_db)
{
if (!_allRowsFetched)
{
// Get the XSQLDA Marshaler
// Reset actual field values
_fields.ResetValues();
// Marshal structures to pointer
if (_fetchSqlDa == IntPtr.Zero)
{
_fetchSqlDa = XsqldaMarshaler.MarshalManagedToNative(_db.Charset, _fields);
}
// Clear the status vector
ClearStatusVector();
// Statement handle to be passed to the fetch method
int stmtHandle = _handle;
// Fetch data
IntPtr status = _db.FbClient.isc_dsql_fetch(_statusVector, ref stmtHandle, IscCodes.SQLDA_VERSION1, _fetchSqlDa);
// Obtain values
Descriptor rowDesc = XsqldaMarshaler.MarshalNativeToManaged(_db.Charset, _fetchSqlDa, true);
if (_fields.Count == rowDesc.Count)
{
// Try to preserve Array Handle information
for (int i = 0; i < _fields.Count; i++)
{
if (_fields[i].IsArray() && _fields[i].ArrayHandle != null)
{
rowDesc[i].ArrayHandle = _fields[i].ArrayHandle;
}
}
}
_fields = rowDesc;
// Parse status vector
_db.ParseStatusVector(_statusVector);
if (status == new IntPtr(100))
{
_allRowsFetched = true;
XsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);
}
else
{
// Set row values
row = new DbValue[_fields.ActualCount];
for (int i = 0; i < row.Length; i++)
{
row[i] = new DbValue(this, _fields[i]);
}
}
}
}
return row;
}
开发者ID:fishcodelib,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:79,代码来源:FesStatement.cs
注:本文中的FirebirdSql.Data.Common.Descriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论