Friday, July 5, 2013

The function import cannot be executed because it is not mapped to a store function



This is very typical error you receive when your underlying database store is changed and there is no update made to EDMX file.
For example, I imported a stored procedure in edmx and saved it. After that I change the stored procedure and do not update edmx. I run the application and at runtime the error is encountered as - “the function import cannot be executed because it is not mapped to a store function”.
This error can be resolved easily by updating the edmx. Following is procedure to resolve the error –
Open the edmx and open Model Browser. Model browser can be opened as shown below.
 
Find the required stored procedure in model browser. The right click and select option – “Delete from Model” as shown below –
 
Now right click on any area on edmx file and select the option “Update Model from Database” option. The popup containing the list of Tables, View and stored procedure will appear. Select the earlier deleted stored procedure and click “Finish” on the pop up.
Now again open the model browser and find the added stored procedure. Right click on it and select the “Edit” option as shown below -

Tuesday, June 25, 2013

Yamaha Ray – A New Step into Indian Two Wheeler Industry by Yamaha – Review and general information



The old runners of Indian roads are about to vanish now. Very popular two wheelers in scooter category like Vespa, Lambretta etc are hard to find these days on Indian roads. The all new, trendy Sports bike has replaced them in recent years. Still, an Indian mentality believes on proverb – OLD IS GOLD. The result is, people try to give new look to old bikes and try to conserve them. YAMAHA’s old bikes like RX100 are still seen on the roads.
YAMAHA bikes are of 2 strokes. That simply means the mileage of Yamaha bikes is way lower as compared to today’s leading two wheeler manufactures in India. Again Indian mentality – “old is gold”; you will find these noise making and heavy fuel drinking Yamaha bikes. The important point to note here is Yamaha never introduced and advertised their bikes as “fuel saver bikes”. In India, Yamaha is more identified for better pick-ups, speedy two wheeler bikes.
 
Yamaha’s position in Indian Market
Yamaha, originally from Japan is spread across all over the world. Two wheeler manufacturing is a small part of Yamaha organization. However, today Yamaha have made presence in whole world. Yamaha is manufacturing two wheelers since 1955. Also Yamaha is well established in Ship engines, helicopters, robots manufacturing. Since start of the company, Yamaha introduced bikes for daily use, bikes for racing and today hundreds of models are present in market.
There was huge demand for Yamaha’s two stroke bikes in India. However, Yamaha’s bikes were popular in a particular class of people. Youth with above average financial condition and who were fond of speed used to think about Yamaha bikes. With the inventions of 4-Stroke engine, fuel saving bikes came to Indian market. The Indian mentality is more leaned towards savings when it comes to money matter. The introduction of 4-stroke based fuel saving bikes changed the focus of Indian people choice for two wheeler bikes. Yamaha quickly spotted this trend and introduced 4-stroke based bikes like Spark, G5, and FZ.  However, the Yamaha still haven’t got the firm base in Indian Market. FZ caught attention, but other Yamaha bikes got very poor response.
 
Yamaha Ray
Based on previous experience Yamaha has stepped in Indian two-wheeler gearless market by introducing Ray. Yamaha Ray was launched in India in September 2012. Yamaha Ray is manufactured and is targeted for Ladies in India. The advertisement of Yamaha Ray was also broad casted to target Indian Ladies. As part of promotion Yamaha launched two wheeler driving sessions for Women. Also Yamaha Ray was manufactured in the plant which was fully operated by Women employees. After this innovative promotion also, Yamaha Ray got poor response from Indian customers. I think Yamaha follows the principle – “try try but never cry”. Yamaha launched again new Gearless two wheeler –

Friday, June 21, 2013

ListBox Data template in WPF MVVM sample



This post talks about using Data Template in WPF – MVVM. As an example I am using ListBox control. The items will be added to listbox based on data template bindings. As basic configuration create a WPF proect. Add View Models folder. I have added another project in the same solution – BusinessLayer. This actually returns list of Tasks that need to be displayed in ListBox. The final solution structure is as follows –
 

Business Layer has a class Task and TaskManager. The TaskManager class is used to create a list of Tasks which will be displayed in ListBox. The Task.cs is as follows –
public class Task
    {
        public string Name { get; set; }
 
        public string Description { get; set; } 

        public int Priority { get; set; }
    }
The TaskManager.cs contains the method to get the list of tasks. As it is very simple; I am skipping it. As part of this sample I have created a ViewModelBase class which contains the implementation of INotifyPropertyChanged  and my specific view model inherits from this base class. The code of my view model class is as follows -  
public class ViewModelBase : INotifyPropertyChanged
    {
       #region INotifyPropertyChanged implementation
        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)

Thursday, June 13, 2013

InkCanvas in WPF – MVVM – StrokeCollection binding


 
After long time, I got some good quality work in this project. Today I used InkCanvas in WPF-MVVM. Then I saved the shapes or drawing drawn within, to database.
Saving anything to database is OK, but the issues is – how do you get the byte array from InkCanvas Strokes? Een the major issue is how do get Strokes from InkCanvas?
Below article explains InkCanvas binding in WPF – MVVM. Alright then, to start with create a WPF project. Have ViewModel folder added in it; to have logic separation from Views. So final Structure of you application will be as follows –

 

Add InkCanvas in your XAML file and Ellipse in it to have drawing within it as written below –
<Window x:Class="StokesCollectionInMVVM.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <InkCanvas Background="Aqua" Strokes="{Binding StrokesEllipse}">
        <Ellipse Height="100" HorizontalAlignment="Left" Margin="116,100,0,0" Name="ellipse1" Stroke="Black" VerticalAlignment="Top" Width="200" />   
        </InkCanvas>
    </Grid>
</Window>

The view model code will be as follows –
Class variables and View model class definition is as follows –
public class MainWindowsViewModel : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged implementation
        public event PropertyChangedEventHandler PropertyChanged; 

        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion 

        #region Class variables       

        private StrokeCollection _strokesEllipse = null;

        #endregion

In constructor – [Note – Code to save byte array in database and retrieve it from database is skipped]
public MainWindowsViewModel()
        {
            //to autopopulate saved drawing on UI -
            //read byte array from say - database and store in EllipseDrawing property
            if (EllipseDrawing != null)
            {
                using (var memoryStream = new MemoryStream(EllipseDrawing))
                {
                    _strokesEllipse = new StrokeCollection(memoryStream);
                }
            }
            else
            {
                _strokesEllipse = new StrokeCollection();
            } 

            (_strokesEllipse as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(MainWindowsViewModel_CollectionChanged);
        }
The handler method of this event is as follows – [Note – Code to save byte array in database and retrieve it from database is skipped]