If you have worked with LINQ and added stored procedures to it, it would seem obvious to be able to it the same way in Entity framework.
In LINQ all you had to do is to drag the stored procedure from your Server Explorer respective data connection on your model diagram.
In entity framework 4, there are few steps and they are different.
1. On your entity diagram in visual studio, right click and choose Update Model from database.
2. Add your stored procedure from the wizard. What it does, it adds the proc to your diagram. Its not visible in .Net code yet.
If you go to Model Browser > {EntityModel}.Store > Stored Procedures, it should be visible in there now
3. Right click, Add > Function Import. Complete this according to your requirement, name of the proc you want to see in .Net, which stored proc it maps to and what is the collection it returns etc.
After step 3 you can access access the proc using an instance of context.
For more visual representation of the steps, please visit WebLog of Ken Cox
Tuesday, August 10, 2010
Wednesday, August 4, 2010
Extracting tags from xhtml content
There are two ways of doing it. One is the dirty way, using Mid function in VB.Net or IndexOf string method but the more appropriate way would be to use regular expressions.
Following code will get you title using regular expression
Following code will get you title using regular expression
Regex regex = new Regex("<title>(?<title>.*?)</title>", RegexOptions.IgnoreCase);Following code will get you meta tag My_Meta
Match titleMatch = regex.Match(html);
string title = titleMatch.Groups["title"].Value;
Regex regex = new Regex("<META +NAME=\"(?<name>My_Meta*?)\" +CONTENT=\"(?<content>.*?)\" */?>", RegexOptions.IgnoreCase);
Match metaMatch = regex.Match(html);
title = metaMatch.Groups["content"].Value;
Labels:
Development,
DotNet,
Technical
Thursday, July 15, 2010
Saving objects using Entity framework
TableClass tableObject = new TableClass();
tableObject.property1 = "Hello";
tableObject.proeprty2 = "World";
// NOTE: make sure to use the same instance of entityContextObject which was used to populate the tableObject (e.g. updating back to database)
entityContextObject.AddToTableClass(tableObject);
entityContextObject.SaveChanges();
tableObject.property1 = "Hello";
tableObject.proeprty2 = "World";
// NOTE: make sure to use the same instance of entityContextObject which was used to populate the tableObject (e.g. updating back to database)
entityContextObject.AddToTableClass(tableObject);
entityContextObject.SaveChanges();
Minimize Outlook 2007/2010 to tray
Very easy fix but it should be a default I think. Anyways in 2 easy steps:
1. Click on outlook icon in Notification area (Beside the clock in task bar)
2. Choose Hide when minimized
Labels:
Productivity
How to minimize MSN Messenger to the system tray in Windows 7
Not sure why Microsoft has changed the behavior in Windows 7 but its annoying that it takes up two programs in task bar when its running. Follow the link below to see the solution.
Labels:
Productivity
Monday, June 28, 2010
Accessing email settings from web.config
Rather than using appSettings, a section from webconfig is a better use for email settings which gives you typed properties in .Net code.
Wednesday, April 14, 2010
What did Apple sold for 2 years comparison
A good graphical comparison of Apple sales between 2008 and 2009
http://www.newmaconline.com/apples-best-selling-products_2010-04-12/
http://www.newmaconline.com/apples-best-selling-products_2010-04-12/
Instant message from any web browser! Try the new Yahoo! Canada Messenger for the Web BETA
Subscribe to:
Posts (Atom)