Archive: March 2012

Loading and Parsing Tweets from a Twitter Feed (Legacy XML API)

Scott Walker · Mar 22, 2012

The LoadTweets() function pulls in a certain amount of tweets from a Twitter account. This function parses the tweet and updates links so that they are clickable.

The URL below will send an XML result. Change the publictimeline to a valid Twitter account and indicate the amount of tweets you need to receive.

http://twitter.com/statuses/user_timeline/publictimeline.xml?count=
đŸ’Ŧ 0 Twitter JavaScript XML

Performing LIKE '%query%' Searches in LINQ

Scott Walker · Mar 16, 2012
When searching and the need arises for LIKE '%query%' using Linq to SQL, use below:

        [Route("search")]
        [HttpPost]
        public IActionResult Search(string search)
        {
            var posts = _db.Posts
                .Where(x => x.Body.Contains(search))
                .Where(x => x.Title.Contains(search)).ToArray();

            ViewBag.SearchCriteria = search;
            ViewBag.TagView = new TagView(_db);

            return View(posts);
        }


Older/Redacted code


using System.Data.Linq.SqlClient;
result = (from b in db.Blogs
   where SqlMethods.Like(b.Title, "%" + keyword + "%") ||  
   SqlMethods.Like(b.Body, "%" + keyword + "%")  
   orderby b.AddedDate descending
   select b);

đŸ’Ŧ 0 Linq SQL