0

I'm trying to pull records from a table (with join) where a text field PassFail must not = PASS not be null/empty but I'm struggling with the syntax. The errors I have had so far point to the syntax I'm using is not supported by linq..

My latest attempt is

Dim HW2Process = (From mi In dc.tblMainDatas
                            Join u In dc.tblUsers On u.UserNo Equals mi.RecdBy
                            Join fi In dc.tblHWs On fi.HWRef Equals mi.HWRef
                            Where mi.Ref.StartsWith(tb_HWRefFind.Text.Trim()) And mi.DateProcessed.HasValue = True And ((mi.PassFail <> "PASS") And (IsNothing(mi.PassFail) = False))
                            Select New With {.ID = mi.ID,
                                                .DateReceived = mi.DateRecd,
                                                .ReceivedBy = u.FullName,
                                                .SerialID = mi.SerialID,
                                                .LiveTest = mi.LiveTest,
                                                .DeployYear = mi. DeployYear,
                                                .ProductType = mi.ProductType,
                                                .HWRef = mi.HWRef,
                                                .HWName = fi.HWName,
                                                .MediaType = mi.MediaType,
                                                .MediaQuantity = mi.MediaQty})

The criteria should be that mi.PassFail should not be null or empty or equal 'PASS'

Any help appreciated.

1 Answer 1

1

You write:

mi.DateProcessed.HasValue = True

Linq2SQL don't have right translation for this. You should write like this:

(Not (mi.DateProcessed Is Nothing))

I suppose same thing here:

(IsNothing(mi.PassFail) = False))

If you want translation of what i see here should be:

(Not (mi.PassFail Is Nothing))

I'm not really in VB, main in C# but i think you get this error becouse if you want to check some value on null you should do it like i mension.

Sign up to request clarification or add additional context in comments.

3 Comments

Linq2ql should handle mi.DateProcessed.HasValue = True
@sgmoore but it is not. Test it. Linq2object does, but not linq2sql
thanks teo van kot... (Not (mi.PassFail Is Nothing)) worked... sgmoore you are correct mi.DateProcessed.HasValue = True does work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.