Archive for Main

PLINQO Tackles LINQ to SQL

Wednesday, November 10th, 2010

So, I’ve been using the basic version of CodeSmith’s Generator product and have mixed feelings about the .netTiers template. It apparently does not like uniqueidentifier fields marked as ROWGUID.

Frankly, I’ve been doing LINQ to SQL for long enough now that I am getting really juiced about using the PLINQO framework with CodeSmith.

The thing is, I love the L2S syntax, but do NOT love using VS-generated DBML files for everything, and Entity Framework sucks.

What’s a brother to do? Hand-code data-context-aware data entities? <sarcasm>Tempting, but no, thanks!</sarcasm>

PLINQO

PLINQO project layout screenEnter PLINQO, a framework that represents your data-aware entities in clear form, with partial classes you’ll need to extend them. The class structure allows for easy detachment from the entities’ data contexts so that you can pass your entities off to your presentation layers and they update the database directly, obviating the need for expensive-to-maintain custom data transfer objects.

PLINQO is built into the Professional Edition of the CodeSmith toolset, which is a template-driven source code generation application, in such a manner that you can generate the framework code automagically straight from your database. What’s coolest of all is that you can re-gen your entities from the database at any time, without it touching your custom code.

I have used the PLINQO’s code generated during my trial period for CodeSmith professional, but now that has lapsed, and I miss it dearly.  In the meantime, I am maintaining the framework code previously generated by hand. Kind of blows, but when I get my new dev studio setup at the home office, I will be getting all manner of new tools, and CodeSmith is one of them.

Using the code is a snap, and being able to integrate the classes out-of-the-box took me from database to business logic in one easy step. Granted, you still have to encode some data rules, but having all the basics in place ready to go meant that I was able to take some sketched out requirements, bang out the basic database structure and got me a data access layer right out of the box.

The PLINQO template can also configure your project to use PLINQO with Data Services and Window Communication Foundation (WCF), though I have yet to grok that.

Its integration into Visual Studio is also godsend, allowing you to update objects without having to leave your dev environment.

One item that makes it worth the price of admission though, is the Enum generator, which takes your look up tables (e.g. Product Types, Scanner Settings, etc.) and creates the Enum class for you. OMFG, I’ve been dying for this for years.

Anyway, take a quick look at the Solution Explorer to the right here. It shows a quick overview of how the PLINQO framework looks when generated by the PLINQO template in CodeSmith.

I am moving into using the ASP.NET MVC framework and want to focus on that, not on the data-access-layer.

The google’s code repository is where the PLINQO sample project Tracker is hosted.

PLINQO :: BOTTOM LINE

This framework has already saved me many hours coding and debugging code for data access, code which is so boring I want to gouge my eyeballs out with pencil. The Visual Studio integration is what LINQ to SQL could have been had Microsoft not dropped the ball in favor of that pig of a beast EF4. Detachable entities and Enum objects round out a top-shelf solution, and those are just what I have grokked so far.

LINQ to SQL multi-keyword search

Thursday, April 15th, 2010

how-to search mutiple keywords using LINQ to SQL

this bit of LINQ code will let you search for records using any number of keywords

it’s a bit limited, but it illustrates the starting point for something more.

the key is to get results for the first keyword into a disconnected object (in this case, a simple List<String>) and then search for the remaining keywords in there. clearly you could up the ante, and select more fields and spin up a collection of custom objects (i.e. List<MyClass>) but this suited my needs for an autocomplete for country names.

// GetMatchesIntersect(string csv, int maxMatches)
// mainly developed for auto-complete scenarios
//
// searches single [n]varchar|text|char field for multiple keywords
//
// returns array of field values containing ALL keywords
//
// NOTE: i decided on array because i am implementing this a webservice
//       to be consumed by other languages/platforms)
public string[] GetMatchesIntersect(string csv, int maxMatches)
{

    // keywords come in as comma-separated values
    string[] keywords = csv.Split(new char[] { ' ', ',' });

    // this list will hold the matches
    List<string> matches;

    using (DbDataContext db = new DbDataContext())
    {

     // build list of matches for first keyword into generic List<string>
     matches = (from s in db.TableToSearch
                where s.FieldToSearch.Contains(keywords[0])
                select s.FieldToSearch).ToList<string>();

     // if any were found
     if (null != matches && matches.Count > 0)
     {
         // start searching at the 2nd keyword (if any)
         for (int i = 1; i < keywords.Length && matches.Count > 0; i++)
         {
          // using .ToUpper() because matching in a List<string> is case-sensitive
          // set matches equal to the query results for each succesive keyword.
          matches = (from match in matches
                  where match.ToUpper().Contains(keywords[i].ToUpper())
                  select match).ToList<string>();
         }
     }
    }
    // ship it out as array
    return matches.Take(maxMatches).ToArray<string>();
}

Anniversary of a Dark Day

Thursday, September 11th, 2008

9/11 is now long enough ago, that when i read e-mails from the time I am surprised by how antiquated my technology was.

i didn’t know anybody who died that day, thankfully.

*moment of silence*

convert heat to electricty via sound

Tuesday, June 12th, 2007

so many processes we employ in our modern world generate heat that goes to waste — from cpu in laptops to nuclear power plant

Orest Symko from the university of utah has found a way to create sound from waste heat and then use that sound to generate electricity

very cool tech http://www.sciencedaily.com/releases/2007/06/070603225026.htm

legalized gange just wasn’t enough, hunh?

Wednesday, June 6th, 2007

Reuters is reporting today that Dutch students have concocted a powered alcoholic beverage that when mixed with water becomes a “a bubbly, lime-colored and -flavored drink with just 3 percent alcohol content.”

called Booz2Go, the target audience is clearly hikers who want to party after a long day but don’t wanna carry all that fluid around.

ha!

article here

now that is high art

Wednesday, May 23rd, 2007

oh how many days seem like this one:

tune in, turn on, and drop out

Wednesday, May 9th, 2007

completely self-contained computer pod
http://www.theoculas.com/gallery.html

flat-screen, surround sound, immersive environment

daddy likey — i want one!

smoking buds

Wednesday, April 25th, 2007

scored me a new pair of ear buds for my ipod, and dude they rock, i’ve got uncle l, and momma said these bud’s will knock you out — bass response to 18Hz, boom bap pow.

only$20 bucks! cheap!

vacation ruled

Tuesday, April 24th, 2007

if you ever get the chance to vacation in the dominican republic, i would totally go for it, in particular, if you have children stay at Melia Caribe resort, very kid friendly, good food, safe environment, fantastic beaches.

my hump

Wednesday, April 11th, 2007

day.

just writing code today and doing a little surfing on the side, nothing too exciting. i want to hit my deadline for the day and bug out of here.