Newsletter: Cialis eli lilly Laetrile Avapro Cheap viagra in uk Cephalexin Buy and purchase viagra online Side effects from viagra Perphenazine Aspartame Inderal Herbal phentermine does it work Bretylium Macrobid Zidovudine Sinemet Dactinomycin Buying phentermine online Avapro Best herbal viagra Neurontin Buy fioricet online Phentermine effects Where to buy viagra online Free cialis Cialis levivia viagra compare 5 no perscription Phentermine result Free phentermine sample Loprox Amantadine Iodoquinol 5 tablet Cheep tramadol paris france Atropine Herbal phentermine forum Cialis experiences Tessalon Norepinephrine Blue 30 mg 90 free shipping phentermine pharmacy Exelon Clarinex Buy Viagra Donepezil Order phentermine by cod Buy cheap phentermine free fedex Lansoprazole Colace Acetaminophen Ethosuximide Cardizem Aricept Buying vicodin online Verapamil Guanabenz Hydrocodone side effects Ritalin Cod tramadol money orders Phentermine from canada Buy xanax without prescription in usa Dofetilide Buy viagra line Lotrel Celecoxib Cialis day next Caffeine Purchase soma 5 cheap Cialis prescriptions Tramadol online discount cheap Viagra compared to levivia Shipping overnight phentermine Butriptyline Lactulose Beconase Seroquel Vicodin abuse Diamox On line doctor phentermine Dangers of taking xanax and neurontin Description tramadol Viagra ingredients Cialis levitra better Buying xanax online Androgel Hydroxyurea Viagra cream Vicodin health Xanax valium Etretinate Permax Xanax look alike Cytarabine Cheap phentermine diet pills Trimeprazine Cephalexin Cheap quality viagra Phentermine international order Buy cheap domain online outdoors com xanax Miconazole Tramadol active ingredient Pravastatin Xanax no prescription required Phentermine ups delivery Cyclobenzaprine Ceftriaxone Buy viagra in the uk Belladonna Buy meridia online Discount fioricet Phentermine and diet pill Xanax indications Female herbal viagra Phentermine guaranteed overnight shipping Buy tramadol without prescription Ambien cr dosage Meridia diet pill Famciclovir Estradiol Aminophylline Diet hcl phentermine pill Symptom tramadol withdrawal Cialis on line Xanax drug information Viagra mexico Atenolol viagra Kevin harvick viagra Cheap tramadol 180 Effects viagra Phentermine drug test Fioricet online Generic xanax photo Buy Zyban Ketorolac Buy phentermine online no prescription Zithromax Ethinamate Buy cheapest online place viagra Low natural resources for the drug phentermine Generic cialis online Phentermine no fees Cheapest tramadol Amitriptyline Is phentermine safe Buy generic hydrocodone Viagra prescription online Phentermine and blood in stool Buy xanax without a prescription Order ambien What is phentermine civ Ciguatoxin What is viagra Ansaid Meridia weight loss pill Hydrocodone m358 Canada xanax Viagra usage Phentermine from mexico Xanax 2mg Chromium Tramadol 377 Claritin Clofazimine Phentermine sales Phentermine diet pill Atorvastatin Pfizer xanax Phentermine buy Viagra tablet Quinine Buy online viagra viagra Doxycycline Pyridoxine Clarithromycin Xanax weight loss Hydrocodone m367 Cheapest free shipping phentermine Phentermine pill online discount Phenytoin interaction with xanax Burn fat lose weight diet phentermine pill Viagra samples Mometasone Oxytetracycline Information on the drug xanax Amlodipine Pink oval pill 17 xanax identification Cialis for woman Fenfluramine Hetacillin Cialis sales uk Augmentin Cheapest phentermine online no prescription Clidinium Free viagra trial Viagra impotence pill Atrovent Suicide xanax 5 free shipping Feldene Butalbital Liqued viagra Phentermine and glucophage Tramadol 100mg Lasix Pfizer xanax pills Pioglitazone Foscarnet Electricity Bush inauguration speech draft viagra bastard of Trichlormethiazide Generic fioricet Olanzapine Ergotamine Lowest drug price for phentermine Diphenoxylate Cheap phentermine without a prescription Soma drug Phentermine hydrochloride Flomax Natural viagra for woman Dangers of viagra Is viagra safe for woman Viagra cream for woman History of phentermine use Xanax withdrawel Thioridazine Cialis levitra sales viagra Milrinone Bexarotene Methsuximide Celecoxib Phentermine 37 5 Coumadin Keflex Metformin Herbal alternative viagra Xanax cod Phentermine side effects Online pharmacy and phentermine overnight Order xanax on line Buy cheap no phentermine prescription Lunesta Buy phentermine prescription Lovastatin Macular degeneration caused by viagra Eldepryl Pharmacy phentermine sister Viagra on line Effexor drug interactions with viagra Order xanax overnight Tramadol information Phentermine adipex diet pill prescription Ramipril Dextromethorphan Low cost viagra Hydrocodone ap ap _cialis et levitra Propofol Phentermine online stores Dexamethasone Chlorpropamide Cialis reviews Phendimetrazine versus phentermine Xanax bar Cialis comparison levitra viagra Picture of xanax pill Levivia viagra online Natural supplement for viagra Phentermine next day Viagra alternative for women Cheapest phentermine diet pill Purchase hydrocodone Sertraline Liver problems from xanax Cyber pharmacy phentermine Cipro 25 mg Xanax and grapefruit Information on phentermine How long does phentermine stay in your body Alternative viagra Oxycontin xanax bars percasettes and lor tabs Lamisil Description of meridia Phentermine wholesale Prescription tramadol Carbarsone Phentermine generic Fluvastatin Amerge Buy Xanax Order vicodin online Valerian Iodoxamate Actonel Podofilox Buy cheap domain online atspace com xanax Female viagra alternative Macrobid Flurbiprofen Phentermine hoodia diet pill Cheap tramadol prescriptions online Cialis generic Tolazamide Meridia versus phentermine Xanax detoxification Adipex Erythrityl Long term side effects of xanax Fluvoxamine Xanax sexual side effects Fosinopril Buy domain online 199mb com tramadol Aprobarbital Anxiety disorder xanax Viagra cialis levitra comparison dosages Blindness cialis Generic vicodin Cheap meridia Between difference levivia viagra Negative side effects of phentermine Phentermine tolerance Alteplase Vicodin overdose 25 mg viagra Hydrocodone query Dosages xanax Nicardipine Phentermine no rx Buy cheap meridia Hydrocodone withdrawal 50mg generic viagra Capoten Buy cialis in uk Phentermine meridia xenical review Viagra treatment migraine headache Bactrim Flovent Xanax withdrawal effects Appetite suppressants equivelant to phentermine Free sample prescription for viagra Amrinone Viagra for woman information Discount phentermine online Viagra discussion Order tramadol cod Cheap viagra order online What does xanax look like Does phentermine work Viagra versand Pentobarbital Lowest price phentermine with free shipping 5 in round white tablets no imprint code Cheapest cialis price Coreg Buy xanax cod Iprindole Phentermine cheap Flosequinan Xanax paypal Why phentermine Cialis order Fast acting viagra Parnaparin Phentermine prescription diet pill Xanax in urine 20mg cialis Lidocaine Online prescription viagra without Paris cheep phentermine Phentermine feedback Natural over counter just like viagra stores Xanax without a prescription Phenoxybenzamine Discount phentermine to florida Glimepiride Mesoridazine Viagra alternative and woman 120 cheap tramadol Without prescription phentermine Adipex meridia phentermine xenical Chlortrimeton Viagra overnight delivery Buying viagra online uk Viagra Noroxin Isopropamide Uk viagra body building from sports supplement Methocarbamol 5 buy online no prescription Buy cod pay phentermine Tramadol narcotic Order phentermine online and cod shipping Albuterol Dexchlorpheniramine Oxycodone Anagrelide Phentermine usa pharmacy How does viagra work Phentermine sales online M357 vicodin Cefepime Fenofibrate Buy Ultram Abilify Tegretol Streptokinase Nonoxynol Order phentermine online Plendil Viagra price Probenecid Benicar Bad side effects of viagra Levitra cialis info Dextroamphetamine Nolvadex Cheap viagra online prescription Cheapest phentermine online free shipping Ups cod phentermine Promethazine Phentermine low price Asparaginase Cheap viagra online Phentermine prescriptions Phentermine pictures Compare pharmacies for phentermine Suboxone Carbenicillin Atracurium Buy Soma Buy vicodin without prescription Phentermine in stock Viagra alternatives On line prescription viagra Uk viagra suppliers Viagra side affects Xanax in early pregnancy Cod phentermine Order viagra viagra online Viagra sale uk Best viagra prices online Viagra useage Prescription viagra Adalat Side effects of phentermine Where can i buy phentermine Compare ionamin phentermine Buy free phentermine shipping Link myblogde online order viagra No perscription xanax Clopidogrel Aldara How to use viagra Best cialis price Free viagra samples Encainide Phentermine without prescription Buy herbal viagra Lowest phentermine Cordarone Phentermine online without a prescription Flagyl Cialis samples Discount meridia Dianabol Vicodin online pharmacy Buy xanax no prescription Free cialis samples Phentermine and carbs Hydrocodone Cialis viagra Fenoterol Caverta veega generic viagra Phentermine pill Generic viagra Ansaid Risperdal Opium Order xanax no prescription Terconazole Flexeril Ambien rx Furazolidone Tramadol drug Phentermine addiction Loss phentermine story success weight Meridia coupon Moricizine Viagra paypal france Esomeprazole Advair Lexapro interaction with phentermine Losartan Leflunomide 5 mg diet pills Purchase tramadol without a prescription Cefotetan Tramadol withdrawal Tramadol ultram Demeclocycline Soma bike Famotidine Phentermine accepts cod Different types of phentermine Free generic viagra samples Black market phentermine Carvedilol Buy online phentermine shipping Phentermine price comparison Order phentermine overnight Phentermine pill town Allowed cialis tag viagra xhtml 5 diet pills Best generic viagra Order tramadol Buy generic xanax Is phentermine discontinued Pentazocine Adapalene Nefazodone Timolol Written prescription for viagra Phentermine vs phentrazine Antazoline 50 mg viagra Trientine Woman use viagra Viagra alternative uk Phentermine blue 30 mg Get phentermine Best buy phentermine Order phentermine No prescription needed phentermine Ethanol Amiloride Granisetron Nitroprusside Spectinomycin Fenoldopam Keyword tramadol Order xanax online Viagra online no prescription Viagra like pill Tramadol 50 mg Bupropion Ativan Viagra libido Buy viagra online cheap Meridia side effects Tramadol drug test Meridia Nicotrol Vicodin and alcohol Ambien 10mg Tramadol and dosage Dantrolene Buy Cialis Melphalan Nexium Iproniazid Dibenzepin Generic viagra fast shipping Xanax side effects Luvox Nadolol Diethylpropion Online consultation xanax Buy xanax online Diet pill xanax Herbal viagra uk Mirtazapine Phentermine pillstore Does xanax show up on drug tests Camphor Erythromycin Cheap phentermine pills Viagra generic brand Viagra pill picture Monopril Cialis pill Secobarbital Soma 350mg Cialis purchase Herbal viagra affiliate Ambien side effect Trovafloxacin Generic viagra online Etodolac Impotence treatment viagra Oxcarbazepine Cialis viagra levivia Methyclothiazide Combivent Buying viagra on line Elocon Percocet Order cialis online Approval cialis fda Levaquin Pentasa Imodium Phentermine money orders Dulcolax 120 tramadol Carphenazine Vincristine Cialis pills Buy online prescription viagra

slholmes.org

Adventures in Semantics

May 15th, 2008

When not to use LINQ to Entities

Recently I have been working on a LINQ to Entities (LE) proof of concept project at my day job. This project is my first experience with LE so the pace has been painfully slow. Fortunately, LE with C# is proving so concise and elegant that I’ve fallen in love. My first project consists of a rather simple Entity Framework model (EF), a web page that allows the eu to select some parameters that are used to build a LE query and display a GridView with the results - basically a simple view of some metrics - Plan versus Actual.

The goal was to write an LE query that shows the metric for the current month, the planned metric and the variance as a percentage.

var getStats = from stats in opsMetrics.StatisticsSet
where stats.FiscalPeriod.FiscalPeriodName == 'MAY_08'
where stats.District.Region.RegionName == 'South Region'
group stats.District.Region.RegionName
into groupedStats
select new
{
PC = groupedStats.Key,
Actual = groupedStats.Sum(p => p.Actual),
Plan = groupedStats.Sum(p => p.Plan)
};

This produces the actual and plan metric for my GridView but I ran into some challenges when I wanted to calculate the percentage difference between the two:

Variance = (Actual/Plan) * 100

Linq to Entities has no percentage extension method. I think it would have confused the daylights out of me anyway. So I decided to create a subquery:


var getPerf = from stats in getStats
select new
{
stats.PC,
stats.Actual,
stats.Plan,
From_Plan = (stats.Actual/stats.Plan) * 100
};

Writing a subquery helps me mentally. I have been writing queries for many years. Nesting queries helps me to formulate unit of work models in my brain. SQL engines usually know how to optimize them and perform in an acceptable way. I like to let the relational calculus do all of the work.

However, there’s a problem in the above snippet. What happens when stats.Plan is zero? The SQL Server database engine reports a divide by zero exception. This can occur naturally when there is no plan. Perhaps there is a new district this year and we did not do the budget for it. We still want to view the district because we want a complete listing of the Region. In this case, we wish to calculate a value of zero for the variance. So, we will fix up our calculation of percentage a little:

var getPerf = from stats in getStats
select new
{
stats.PC,
stats.Actual,
stats.Plan,
From_Plan = (stats.Plan==0) ? 0 : (stats.Actual/stats.Plan) * 100

};

Now to be honest this is not exactly what I want. I really and to see the From_Plan column show a percent sign “%” on the grid. So what I really want is a formatted string. If we just add the conversion and then concatenate the “%” sign, the From_Plan calculation is getting way more convoluted than it needs to be. So, I’d like to call a function that does all of the havy lifting:

var getPerf = from stats in getStats
select new
{
stats.PC,
stats.Actual,
stats.Plan,
From_Plan = safePercentString(stats.Actual, stats.Plan)
};

Then we just implement a simple procedure called safePercentSign.


protected string safePercentString(decimal? inTop, decimal? inBot)
{
decimal result=0;
if (inBot != 0) result = (decimal)(inTop / inBot)*100;
return (result==0) ? “-” : result.ToString(”0,0.0″) + ” %”;
}
protected string safePercentString(int? inTop, int? inBot)
{
return safePercentString((decimal?) inTop,(decimal?) inBot);
}

The above will build and not produce an error but at run time, (in my case during the GridView.DataBind()), LINQ to Entities complains that safePercentString is an unknown thingermajigger (I forget what the actual exception is). Obviously, LE is unhappy with what we may consider an “external function call”. External in that my intent is that LINQ to Entities would just automagically call my procedure.

As it happens, LINQ to Entities fails to issue the query simply because it is unable to produce any SQL that would actually result in what I intended. Honestly, when you are this deep into LINQ you forget all about there even being any SQL involved because it’s all objects.

Objects! That’s the solution. We don’t want LINQ to Entities to calculate and convert the percentage at all. We want C# to do that. So the solution is simple. We convert the query to a LINQ to Objects query:

var getPerf = from stats in getStats.AsEnumerable()
select new
{
stats.PC,
stats.Actual,
stats.Plan,
From_Plan = safePercentString(stats.Actual, stats.Plan)
};

The .AsEnumerable() extension method causes LINQ to Entities the enumerate the results into something LINQ to Objects can work with. LINQ to Objects has no problem calling my C# procedure.

Separate the Linq to Entities unit of work of retrieving the records you need to produce the prep to render unit of work using Linq to Objects. I’ve used this practice on a number of other occasions since and it dramatically boosts my productivity.

January 3rd, 2008

More on the Ontology Design Document

I have spent the better part of the last two weeks working on the formatting of the Ontology Design Document. The document itself has a variety of features:

  • Valid markup
  • XHTML, MathML and SVG for content
  • CSS for presentation styling

I am using the following Open Source software tools to author the document:

  • Amaya
    • Provides features for authoring XHTML and MathML in a WYSIWYG environment
    • Provides support for SVG documents and inline SVG
    • Provides basic support for authoring CSS style sheets
    • Under active development for years and very mature
  • Inkscape
    • Provides features for authoring SVG documents in a WYSIWYG environment
    • Very advanced and streamlined vector graphics editor
    • Under active development for years and very mature

After years of searching for “just the right tool set”, I think I’ve finally found it. It is funny how that tool set was one of the first ones I looked at back in 2001. Both tools have come a long way since then. In order to maximize the utility of the tool set, it helps to have a strong understanding of W3 recommendations, particularly in the case of Amaya.

Amaya is one of the few XHTML editors that actually generate <strong> and <em> elements when you click their respective tools on the tool pallet. Amaya support for tables is first class and generates exactly the code you expect and nothing else. The MathML pallet makes entering formulas very easy. The documentation is very strong and helpful for those times when you run into gray areas. Amaya hides most of the underlying markup in its default view.  A handy splitter bar is provided that toggles the markup view on and off so you can see the WYSIWYG presentation and the markup at the same time.

Inkscape is one of those drawing tools that just gets better the more you use it. The basic drawing pallet makes sense and after a quick visit to one of the tutorial pages, you can quickly put together some pretty neat drawings. After a while, you’ll begin to learn how the objects and layers work and can then concentrate on some pretty advanced features. When incorporating SVG into XHTML documents, it is important to know that not all browsers support all features so adequate testing will still be required.

To use Inkscape SVG drawings inline within an XHTML document constructed with Amaya, follow these steps:

  1. “Save As” the Inkscape drawing using the “Plain SVG” output type.
  2. Open the SVG drawing in Amaya. Verify that Amaya is rendering what you expected.
  3. Use the F2 function key to select the entire drawing up to and including the SVG tag.
  4. Right click the selection and select Copy
  5. Switch to your XHTML document and locate your insertion point.
  6. Right click then insertion point and select Paste.

To make a document in Amaya that handles XHTML, MathML and SVG, follow these steps:

  1. Select File.New.New XHTML Document
  2. Name your document in the New XHTML Document dialog
  3. Change the Document Profile to “Compound Document”
  4. Leave the extension “XML” - Required by Gecko browsers such as Mozilla

In order to correctly work with MathML, you’ll need the following XSLT style sheets (more information):

  • mathml.xsl
  • pmathml.xsl
  • ctop.xsl
  • pmathmlcss.xsl

Although Amaya and Inkscape working together is not overly complicated, there are a number of steps to get your document orchestrated but this is true of any environment. Look carefully over the Amaya documentation. The style of writing is very compact but don’t let that mislead you. The documentation is complete and very helpful. Also, Amaya has a very active user community.

December 26th, 2007

Ruby and Rails

Microsoft recently announced that .NET will include support for MVC - Model, View Controller and has provided a community technology preview (CTP).

December 15th, 2007

Adventures in Semantics - New Home

Movement from SquareSpace to WordPress

The new home for Adventures in Semantics is up and running. Moved over the old posts from SquareSpace to my private yahoo site. Need to edit the old posts a little more. The comments did not import in as comments. I’ll probably leave those alone as most of the content and comments are fairly old. SquareSpace was entirely too difficult to use and very slow.

Ontology Design Document

The work on the Ontology Design document is progressing. I’m using the Amaya editor from W3C. This is a very rough draft. Citations are a mess. It is not very useful in its current state but hopefully that will change over time.