Is there way to write multiple conditions of LINQ in single command in vb.net

I've a below code to filtering my files but it's a bit hard way because i declare it in if end if loop and other variables which using it cannot seee it i wonder is there any possible way to simplify this;

Any help would be grateful. Thank you.

                If My.Settings.user_build__list_prt = False Then

                    Dim getHp = From group In subvarGroupList
                                Where group.fullName.EndsWith(My.Settings.str_elem__subvar_grpname_hp) AndAlso Path.GetFileNameWithoutExtension(group.origin).StartsWith("prt_") = My.Settings.user_build__list_prt
                                Select group
                Else
                    Dim getHp = From group In subvarGroupList
                                Where group.fullName.EndsWith(My.Settings.str_elem__subvar_grpname_hp)
                                Select group
                End If

Open in new window

HakanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
Hakan

Not sure about doing it all in one command/statement but perhaps you could try it something like this.
Dim getHp = From group In subvarGroupList
            Where group.fullName.EndsWith(My.Settings.str_elem__subvar_grpname_hp)
            Select group

If My.Settings.user_build__list_prt = False Then
	getHp.Where(Path.GetFileNameWithoutExtension(group.origin).StartsWith("prt_") = My.Settings.user_build__list_prt)

Open in new window

That, to me anyway, makes things a little clearer.
it_saigeDeveloperCommented:
You could always declare your variable outside of the if block; e.g. -
Dim getHp As IEnumerable(Of Group)
If My.Settings.user_build__list_prt = False Then
    getHp = From group In subvarGroupList 
                   Where group.fullName.EndsWith(My.Settings.str_elem__subvar_grpname_hp) 
                   AndAlso Path.GetFileNameWithoutExtension(group.origin).StartsWith("prt_") = My.Settings.user_build__list_prt
                   Select group
Else
    getHp = From group In subvarGroupList 
                   Where group.fullName.EndsWith(My.Settings.str_elem__subvar_grpname_hp) 
                   Select group
End If

Open in new window

-saige-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.