示例#1
0
        public string Lookup(string searchData, string searchField, string returnField)
        {
            // checks if the search field contains the search data and returns the return field data, no match returns null
            if (searchData != null)// && searchData.Equals(GetByField(searchField), StringComparison.CurrentCultureIgnoreCase))
            {
                DefaultConnectionEntities db = new DefaultConnectionEntities();
                Reaction reaction;
                switch (searchField)
                {
                case "Object":
                    reaction = (from u in db.Reactions where u.Object == searchData select u).FirstOrDefault();
                    break;

                case "Mood":
                    reaction = (from u in db.Reactions where u.Mood == searchData select u).FirstOrDefault();
                    break;

                case "Action":
                    reaction = (from u in db.Reactions where u.Action == searchData select u).FirstOrDefault();
                    break;

                case "Emoji":
                    reaction = (from u in db.Reactions where u.Emoji == searchData select u).FirstOrDefault();
                    break;

                default:
                    return(null);
                }
                return(reaction.GetByField(returnField));
            }
            return(null);
        }