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

  • SEARCH
  • Home
  • 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 6555579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:50:15+00:00 2026-05-25T12:50:15+00:00

Forgive me if my question is technically worded wrong but I basically need an

  • 0

Forgive me if my question is technically worded wrong but I basically need an anonymous method or a Func delegate to encapsulate the following functionality:

                if (Cache.CurrentCustomer == null)
                {
                    return null;
                }
                else
                {
                    return Cache.CurrentCustomer.PersonID; // (Guid type)
                }

The above if statement will return a value that is going to be assigned against an Order entity that has a PersonID property field exposed that accepts a nullable guid type.

If a Func delegate is possible then can instantiate on the fly like:

orderToInsert.PersonID = new Func() => { ... }

I would typically ship my if statement scenario out into a help support method this is a good opportunity to learn something I have been trying to pick for ages! TIA!!!

  • 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-25T12:50:16+00:00Added an answer on May 25, 2026 at 12:50 pm

    Here it is in lambda form:

    Func<Guid?> lambda = () => Cache.CurrentCustomer == null 
                                 ? (Guid?)null 
                                 : Cache.CurrentCustomer.PersonID;
    

    You would then use it as in

    orderToInsert.PersonID = lambda();
    

    Update: If you are only trying to see what’s possible here, then you can also do this:

    orderToInsert.PersonID = (() => Cache.CurrentCustomer == null 
                                 ? (Guid?)null 
                                 : Cache.CurrentCustomer.PersonID)();
    

    which is really just a roundabout way of doing the classic:

    orderToInsert.PersonID = Cache.CurrentCustomer == null 
                                 ? (Guid?)null 
                                 : Cache.CurrentCustomer.PersonID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please forgive the noob question but I'm going round in circles and need answers...
forgive my newbie question, but why finding by '2' or '2' in Mysql returns
Forgive me for a potentially silly question here, but in other programming languages (scripting
Forgive me for this noob question, but is there such a setting that sets
Forgive me if this is a particularly stupid question! mysql_query($query) returns a boolean, but
I'm new to JPA, so forgive this question if this is pretty standard functionality,
Please forgive the newb question, but I am not finding answers elsewhere... probably because
Forgive me if my question is stupid, but I'm not a web programmer and
Forgive my ignorance if this is 'a basic question'..... I have a method that
Forgive my elementary question as I'm pretty new to cocos2d, but I'm having an

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.