Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3487232
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:07:27+00:00 2026-05-18T11:07:27+00:00

I am exploring Silverlight (C#) and SQLServer as a next evolution for our current

  • 0

I am exploring Silverlight (C#) and SQLServer as a next evolution for our current (slow) Access database. So far everything has been great, using DomainServices to retrieve the data I need. In our database we have a table (Supervisors) with Supervisor_ID, Supervisor_FirstName, Supervisor_LastName and many other fields.

What I want to do is recreate a function I use in my current database called EntityNameFirstLast(EntityID) which would take an integer. I could then retrieve the value of [Supervisor_FirstName] from [Supervisors] table where [Supervisor_ID] == EntityID using the following:
FirstName = DLookup(“[Supervisor_FirstName]”, “Supervisors”, “[Supervisor_ID] = EntityID

I would do the same for lastname and combine the strings returning one string with First and last name.

How can I get just a single value from my database through my DomainService (or any way for that matter)? I understand that IQueryable GetSupervisorByID(Int SupID) will return the entire row that I need, but how can I get a specific field from that row?

I am also aware that I can set the DomainDataSource in my XAML and then bind to the data I want, but I am curious if what I asked above is doable or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:07:28+00:00Added an answer on May 18, 2026 at 11:07 am

    There are number of ways you can accomplish your requirement if what you need is a single value from MS-SQL server:

    1.Use a Query to do the concatenation and then use its output in your code

    Select Supervisor_FirstName + ' ' + Supervisor_LastName as Supervisor_FullName From Supervisors Where Supervisor_ID = EntityID
    

    Now you can get the above query to execute through a SqlCommand and get the part thats interesting to you

    private string GetSupervisorFullName(string entityID, string connectionString) {
        string query = "Select Supervisor_FirstName + ' ' + Supervisor_LastName as Supervisor_FullName From Supervisors Where Supervisor_ID = @EntityID";
        string supervisorFullname = "";
    
        using(SqlConnection con = new SqlConnection(connectionString)) {
            SqlCommand cmdSupervisorFullname = new SqlCommand();
            cmdSupervisorFullname.Connection = con;
            cmdSupervisorFullname.CommandText = query;
            cmdSupervisorFullname.CommandType = CommandType.Text;
    
            SqlParameter paraEntityID = new SqlParameter();
            paraEntityID.ParameterName = "@EntityID";
            paraEntityID.SqlDbType = SqlDbType.NVarChar;
            paraEntityID.Direction = ParameterDirection.Input;
            paraEntityID.Value = entityID;
    
            cmdSupervisorFullname.Parameters.Add(paraEntityID);
    
            try {
                con.Open();
                supervisorFullname = (String) cmdSupervisorFullname.ExecuteScalar();
            } catch(Exception ex) {
                Console.WriteLine(ex.Message);
            }
    
            return supervisorFullname;
        }
    }
    

    2.Second way would be create a Scalar function in the SQL for your requirement and then access that function using the same kind of method as mentioned above.

    Then finally you would take the return value from your method GetSupervisorFullName and populate any control value of your choice.

    Please do note that there are again other methods of doing the same with LINQtoSQL or with any other ORM tools. The above 2 methods are the basic way of accomplishing them.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been exploring different strategies for running integration tests within some Nant build scripts.
I'm thinking about exploring the idea of having our client software run as a
I've been exploring use of MSys lately as an alternative, 'nix-like shell for my
Does anyone know of a good open source plugin for database querying and exploring
I am exploring the Silverlight attached behaviors mechanism in order to use the Model-View-ViewModel
What I'm trying to attempt is to access methods on a Silverlight control via
First off, apologies if this question has been asked before but I couldn't find
while exploring jQuery I came up with the following weird script. I don't see
I'm exploring the possibility of writing an application in Erlang, but it would need
I'm exploring the XML -> XSLT -> HTML meme for producing web content. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.