Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Linq, stored procedure with timestamp output column

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy - 20 Mar 2008 21:05 GMT
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?
Andy - 21 Mar 2008 16:37 GMT
> Hi,
>
[quoted text clipped - 62 lines]
>
> Any ideas?

I found the answer; if your ParamterAttribute DbType = "timestamp" you
MUST have the parameter type to the method to be
System.Data.Linq.Binary.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.