A
Andy
Hi,
I am trying to use linq to sql to call a stored procedure.
Here's the proc signature:
CREATE PROCEDURE [dbo].[apConvertDocument]
@FromDocumentId int,
@FromDocumentVersion timestamp,
@CloseFromDocument bit,
@NewDocumentType char(1),
@NewDocumentId int output,
@NewDocumentVersion timestamp output
AS
-- do stuff
Here's the code I'm using to call the sp:
[Function( Name = "dbo.apCorrectInvoice", IsComposable = false )]
public int apCorrectInvoice(
[Parameter( Name = "DocumentId", DbType = "Int" )]
int? documentId,
[Parameter( Name = "DocumentVersion", DbType = "Timestamp" )]
byte[] documentVersion,
[Parameter( Name = "CreditMemoId", DbType = "Int" )]
ref int? creditMemoId,
[Parameter( Name = "CreditMemoVersion", DbType = "Timestamp" )]
ref byte[] creditMemoVersion,
[Parameter( Name = "NewInvoiceId", DbType = "Int" )]
ref int? newInvoiceId,
[Parameter( Name = "NewInvoiceVersion", DbType = "Timestamp" )]
ref byte[] newInvoiceVersion
) {
Binary tmp = new Binary( new byte[ 8 ] );
Binary tmp2 = new Binary( new byte[ 8 ] );
IExecuteResult result =
ExecuteMethodCall(
this,
(MethodInfo)MethodInfo.GetCurrentMethod(),
documentId,
new Binary( documentVersion ),
creditMemoId,
tmp,
newInvoiceId,
tmp2
);
creditMemoId = (int?)result.GetParameterValue( 2 );
creditMemoVersion =
( (Binary)result.GetParameterValue( 3 ) ).ToArray();
newInvoiceId = (int?)result.GetParameterValue( 4 );
newInvoiceVersion =
( (Binary)result.GetParameterValue( 5 ) ).ToArray();
return (int)result.ReturnValue;
}
No matter what I do, I get the following exception:
System.ArgumentException: Argument types do not match
at System.Linq.Expressions.Expression.Constant(Object value, Type
type)
at System.Data.Linq.DataContext.GetMethodCall(Object instance,
MethodInfo methodInfo, Object[] parameters)
at System.Data.Linq.DataContext.ExecuteMethodCall(Object instance,
MethodInfo methodInfo, Object[] parameters)
Any ideas?
I am trying to use linq to sql to call a stored procedure.
Here's the proc signature:
CREATE PROCEDURE [dbo].[apConvertDocument]
@FromDocumentId int,
@FromDocumentVersion timestamp,
@CloseFromDocument bit,
@NewDocumentType char(1),
@NewDocumentId int output,
@NewDocumentVersion timestamp output
AS
-- do stuff
Here's the code I'm using to call the sp:
[Function( Name = "dbo.apCorrectInvoice", IsComposable = false )]
public int apCorrectInvoice(
[Parameter( Name = "DocumentId", DbType = "Int" )]
int? documentId,
[Parameter( Name = "DocumentVersion", DbType = "Timestamp" )]
byte[] documentVersion,
[Parameter( Name = "CreditMemoId", DbType = "Int" )]
ref int? creditMemoId,
[Parameter( Name = "CreditMemoVersion", DbType = "Timestamp" )]
ref byte[] creditMemoVersion,
[Parameter( Name = "NewInvoiceId", DbType = "Int" )]
ref int? newInvoiceId,
[Parameter( Name = "NewInvoiceVersion", DbType = "Timestamp" )]
ref byte[] newInvoiceVersion
) {
Binary tmp = new Binary( new byte[ 8 ] );
Binary tmp2 = new Binary( new byte[ 8 ] );
IExecuteResult result =
ExecuteMethodCall(
this,
(MethodInfo)MethodInfo.GetCurrentMethod(),
documentId,
new Binary( documentVersion ),
creditMemoId,
tmp,
newInvoiceId,
tmp2
);
creditMemoId = (int?)result.GetParameterValue( 2 );
creditMemoVersion =
( (Binary)result.GetParameterValue( 3 ) ).ToArray();
newInvoiceId = (int?)result.GetParameterValue( 4 );
newInvoiceVersion =
( (Binary)result.GetParameterValue( 5 ) ).ToArray();
return (int)result.ReturnValue;
}
No matter what I do, I get the following exception:
System.ArgumentException: Argument types do not match
at System.Linq.Expressions.Expression.Constant(Object value, Type
type)
at System.Data.Linq.DataContext.GetMethodCall(Object instance,
MethodInfo methodInfo, Object[] parameters)
at System.Data.Linq.DataContext.ExecuteMethodCall(Object instance,
MethodInfo methodInfo, Object[] parameters)
Any ideas?