In general, getting EF work with MySQL is a fairly simple task, that could be accomplished by downloading and installing ADO.NET driver for MySQL. But what concerns to me, it taken me about four hours to clarify some MySQL-specific details that affect generation of associations in Model Designer. Also after doing an experimentation with the code I realized that ADO.NET driver for MySQL, as well as other third party ADO.NET drivers, do not support “MARS” and, as far as I see, this significant restriction makes EF unusable with MySQL in large real-life projects. Please read below if you interested in more information on this questions.
(more…)
Category Archives: Programming languages
Using ADO.NET Entity Framework with MySQL
Seeing design time data in a WPF control
Sometimes the ability to see the data at design time significantly facilitates the creation of WPF controls. If I am developing a WPF control with complex UI using data bound controls, I usually define a property for accessing some typical data item:
public static ComplexData DesignTimeItem { get { using (DatabaseContext db = new DatabaseContext()) { var products = from p in db.products.Include("ProductType") where p.product_id == 131 select p; product product = products.First(); return new ComplexData(product, "100 kg"); } } }
Adding footers and meta tags to WordPress posts
Adding post footer
There are a lot of plugins for adding footers to WordPress posts and one of them is so called “Add Post URL” plugin written by some Chinese guys. From my perspective, its benefits includes macros support and ability to decide whether or not to display the footer for each post individually. It worked fine for me and I even improved it a little bit. The following code snippet shows how I added “post_id” macro:
$footer_text = $posturl_options['footer_text']; $footer_text = trim($footer_text); if (!empty($footer_text)) { //remove_filter( 'the_content', 'wpautop' ); $post_id = get_the_ID(); $footer_text = str_replace("%post_id%", $post_id, $footer_text); $footer_text = str_replace("%site_url%", site_url('/'), $footer_text); $footer_text = str_replace("%site_name%", get_bloginfo('sitename'), $footer_text); $footer_text = str_replace("%post_url%", get_permalink(), $footer_text); $footer_text = str_replace("%post_title%", the_title('', '', false), $footer_text); $footer_text = stripslashes($footer_text); $text .= $footer_text; }
Getting WordPress multisite work with Windows Live Writer
Windows Live Writer is configured for working with WordPress multi-site the same way as with normal single-site WordPress installation, but WordPress works a bit differently in multi-site and single-site configurations. The difference consists in a few lines of code in wp-includes/class-wp-xmlrpc-server.php:
function wp_getUsersBlogs( $args ) { global $current_site; // If this isn't on WPMU then just use blogger_getUsersBlogs if ( !is_multisite() ) { array_unshift( $args, 1 ); return $this->blogger_getUsersBlogs( $args ); } //single-site verion... }
How to modify product page title in VirtueMart 1.1.9, Joomla 1.5.23
Function $document->setTitle($title) is called from “administrator/components/com_virtuemart/classes/mainframe.class.php”:
function setPageTitle( $title ) { global $mainframe; $title = strip_tags(str_replace(' ',' ', $title)); $title = trim($title); if( defined( '_VM_IS_BACKEND')) { echo vmCommonHTML::scriptTag('', "//<![CDATA[ var vm_page_title=\"".str_replace('"', '\"', $title )."\"; try{ parent.document.title = vm_page_title; } catch(e) { document.title =vm_page_title; } //]]> "); } elseif( vmIsJoomla('1.5') ) { $document=& JFactory::getDocument(); $document->setTitle($title); } else { $mainframe->setPageTitle( $title ); } }
Progressive discounts in VirtueMart
I did some investigation of VirtueMart 1.1.x discount system and the first thing I did notice is that VirtueMart 1.1.x does not support progressive discounts natively. In other words it does not allow to define the discount based on the amount of products bought or total amount of money paid.