Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Is there a way to get a link query to return a row from a table?

$
0
0

So I am trying to access a database table that has a field that I need to match and if there is a match I need to select data out a field in  that table. I have tried and few things and I am coming up with nothing. 

So here is what I have so far

    Function GetCurrentUserEmail() As String

        'Get Current System Client Info
        'Check xxxxx View to get the User's Email 

        Dim CurrentUser As String = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name
       
'Dim Users As VUE_xxxxxx_EMPLOYEE_DIVISONS = XXXdb.VUE_xxxxx_EMPLOYEE_DIVISONS.SingleOrDefault(Function(u) u.Network_ID.Contains(CurrentUser)) 'Dim UserEmail = Users.Email.ToString() Dim UserEmail = From Users In XXXdb.VUE_XXXX_EMPLOYEE_DIVISONS Where Users.Network_ID = "%" & CurrentUser & "%," Select Users.Email Dim Test = UserEmail.ToString() Return Test End Function

What I would like to have is a Sql "Like" selection 

So if the Current User matches the network ID then I want to select that users email address from the table and send it back to the 

function that called it. 

I find link a bit confusing as there is more than one way to wright a query but there is never giving any reasons why you would use the lambda thing over the from option.

Same with where.  I thought contain would work but that seems like a useless option.

But any help or guidance would be most appreciated! Thanks


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>