LINQ to SQL Help doing update in VB RRS feed

  • Question

  • Hi.
    I have been enjoying LINQ to SQL for a while now. I just read a post saying that it is dead and I hope that will not happen as it makes my SQL so much easier. My problem is as follows, I have a whole site in C# but the payment gateway gave me a sample of how to implement their system and they only have a VB example. This has happened to me on another site but I found a blog on how to have some pages and classes in C# and other in VB so no problem.

    On this site however I am using LINQ and on the other one I used table adapters. I do not want to revert to using table adapters on only this page as I am sure that this must work. All I have to do is write a simple update to the DB on this page to finish it. The C# for doing this would be:

    string strVendorTxCode = Request.Querystring["vendorTxCode"].ToString();
    WeddingListsDataContext wlDB = new WeddingListsDataContext();
    var thisCount = wlDB.Payments.Count(p=>p.vendortTxCode==strVendorTxCode).First()
      Payment thisPayment = wlDB.Payments.Where(p=>p.vendortTxCode==strVendorTxCode)
      thisPayment.sentMail = true;
     //And here I send the mail

    In VB I have:
    Private wlDB As New WeddingListsDataContext()
            Dim thisPayment = From p In wlDB.Payments Where (p.ToString() = strVendorTxCode)
            Select p

    and here it complains that: Expression of type 'System.Data.Linq.Table(Of Payment)' is not queryable ???

    Any help please?

    Thank you

    Sarel j Smit
    Sunday, February 1, 2009 9:52 PM


  • You can't query the ToString() of a payment as it has no translation to the underlying store. Try using the field in the original sample, e.g.

            Dim thisPayment = From p In wlDB.Payments Where (p.vendortTxCode = strVendorTxCode)

    Friday, March 6, 2009 9:55 PM