Skip to content

Random Bits

Try using this for initializing a dropdownlist

string[,] siblings = { {“Mike”, “Amy”}, {“Mary”, “Albert”} };

Working with Shapes: http://msdn.microsoft.com/en-us/library/bb545007.aspx

For pulling data from the .cscfg file on azure, there are three parts:

  1. Update ServiceConfiguration.cscfg to include an entry like this:
    • <ConfigurationSettings>…<Setting name=”FaceBookApplicationKey” value=”xyzpdq” /></ConfigurationSettings>
  2. Update ServiceDefinition.csdef to include an entry like this (same as above, but without the value):
    • <ConfigurationSettings>…<Setting name=”FaceBookApplicationKey”  /></ConfigurationSettings>
  3. Now you can reference this in your controllers or code behinds like this:
    • using Microsoft.WindowsAzure.ServiceRuntime;
    • var tolerance = RoleEnvironment.GetConfigurationSettingValue(“FaceBookApplicationKey”);

This enables you to modify parameters while your application is running and without re-uploading/restarting/waiting (forever). Useful for logic that distinguishes between local and live settings.

Create a class with a static select list:
    public class ProfileInformation
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string GenderType { get; set; }
        public DateTime? BirthDate { get; set; }
        public string Website { get; set; }

        public string City { get; set; }
        public string State { get; set; }
        public string Country { get; set; }

        public static SelectList GetGenderList(String gender)
        {
            List<SelectListItem> genderList = new List<SelectListItem>()
            {
                new SelectListItem() { Value = "M", Text = "Male" },
                new SelectListItem() { Value = "F", Text = "Female" }
            };
            return new SelectList(genderList, "Value", "Text", gender ?? "M");
        }

    }
Compare strings, case insensitive (works with Linq)

var

 

 
q = (from userProfile in _entities.Select()where String.Equals(userProfile.UserName, userName, StringComparison.OrdinalIgnoreCase) && userProfile.PhoneNumber == passwordselect userProfile).SingleOrDefault();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: