<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://community.omnicom.no/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Lars-Erik&amp;#39;s blog</title><link>http://community.omnicom.no/blogs/lea/default.aspx</link><description>.net, sql and everyday life from norwegian developer Lars-Erik Aabech</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Tired of DropDownList "has a SelectedValue which is invalid because it does not exist in the list of items."</title><link>http://community.omnicom.no/blogs/lea/archive/2009/07/06/tired-of-quot-has-a-selectedvalue-which-is-invalid-because-it-does-not-exist-in-the-list-of-items-quot.aspx</link><pubDate>Mon, 06 Jul 2009 09:18:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:33</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=33</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=33</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2009/07/06/tired-of-quot-has-a-selectedvalue-which-is-invalid-because-it-does-not-exist-in-the-list-of-items-quot.aspx#comments</comments><description>&lt;p&gt;Before anything, I have to say that I do not advocate uncritical use of this solution. A good system should validate all input and keep its entities valid at all times. If you end up needing this one, you shold be needing it because you&amp;#39;re creating a quick fix in a legacy system, or you&amp;#39;re working with something that _should_ have errors. :)&lt;/p&gt;
&lt;p&gt;My particular need just now is that I&amp;#39;m introducing a dropdown for a freetext field in a system I inherited. Its using LINQ to SQL datasources and no business layer what-so-ever, and I&amp;#39;m not about to make on on my 4 hour budget.&lt;/p&gt;
&lt;p&gt;Anyway, according to this feedback post, I&amp;#39;m guessing MS isn&amp;#39;t gonna bake this into the .net framework anytime soon.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=260603"&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=260603&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So here&amp;#39;s an inherited DropDownList that does exactly that. :)&lt;br /&gt;(Pretty quick and easy, so I guess that&amp;#39;s why we don&amp;#39;t get one in the box)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: It iterates over the items in the list one extra time, so it does degrade performance!&lt;/em&gt;&lt;/p&gt;&lt;pre&gt;public class ForgivingDropDownList : DropDownList
{
	[Category(&amp;quot;Behavior&amp;quot;), DefaultValue(true)]
	public bool AllowInvalidSelectedValue
	{
		get { return ViewState[&amp;quot;allowInvalid&amp;quot;] != null ? (bool)ViewState[&amp;quot;allowInvalid&amp;quot;] : true; }
		set { ViewState[&amp;quot;allowInvalid&amp;quot;] = value; }
	}

	public override string SelectedValue
	{
		get
		{
			return base.SelectedValue;
		}
		set
		{
			if (!AllowInvalidSelectedValue)
			{
				base.SelectedValue = value;
				return;
			}

			if (this.Items.Count != 0)
			{
				if ((value == null) || (base.DesignMode &amp;amp;&amp;amp; (value.Length == 0)))
				{
					this.ClearSelection();
					return;
				}
				ListItem item = this.Items.FindByValue(value);
				if (item == null)
				{
					base.SelectedValue = null;
					return;
				}

				base.SelectedValue = value;
			}
		}
	}
}
&lt;/pre&gt;
&lt;p&gt;And here&amp;#39;s some simple sample usage:&lt;/p&gt;&lt;pre&gt;&amp;lt;asp:FormView ID=&amp;quot;FormView1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;
	&amp;lt;EditItemTemplate&amp;gt;
		&amp;lt;cc1:ForgivingDropDownList ID=&amp;quot;ForgivingDropDownList1&amp;quot; runat=&amp;quot;server&amp;quot; SelectedValue=&amp;#39;&amp;lt;%# Bind(&amp;quot;Text&amp;quot;) %&amp;gt;&amp;#39;&amp;gt;
			&amp;lt;asp:ListItem&amp;gt;a&amp;lt;/asp:ListItem&amp;gt;
			&amp;lt;asp:ListItem&amp;gt;b&amp;lt;/asp:ListItem&amp;gt;
		&amp;lt;/cc1:ForgivingDropDownList&amp;gt;
	&amp;lt;/EditItemTemplate&amp;gt;
&amp;lt;/asp:FormView&amp;gt;


public class Thing
{
	public string Text { get; set; }
}

public partial class ForgivingDropDownPage : System.Web.UI.Page
{
	protected void Page_Load( object sender, EventArgs e )
	{
		if (!IsPostBack)
		{
			FormView1.DefaultMode = FormViewMode.Edit;
			FormView1.DataSource = new Thing[] { new Thing { Text = &amp;quot;c&amp;quot; } };
			FormView1.DataBind();
		}
	}
}

&lt;/pre&gt;
&lt;p&gt;And that&amp;#39;s it. :) Enjoy!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=33" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/whining/default.aspx">whining</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Tired of "OnEvent", just fire already!</title><link>http://community.omnicom.no/blogs/lea/archive/2009/06/04/tired-of-quot-onevent-quot-just-fire-already.aspx</link><pubDate>Wed, 03 Jun 2009 18:43:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:32</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=32</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=32</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2009/06/04/tired-of-quot-onevent-quot-just-fire-already.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve been writing one too many protected void OnThisEvent() and OnThatEvent() handlers lately, and what&amp;#39;s bugging me the most is having to if (Event != null) every time.&lt;/p&gt;
&lt;p&gt;So I wrote a wee little helper giving me just a wee bit less code to write when I want to fire an(y) event.&lt;/p&gt;
&lt;p&gt;Trick is it has to be used from the exact class (even if the event is in the base class) the event is declared, so you still need protected void OnThisEvent() for base classes to fire it, but it&amp;#39;s still a bit neater I think. It kind of says &amp;quot;I&amp;#39;m telling my observers this happened&amp;quot; instead of &amp;quot;I might be doing something now&amp;quot;. :)&lt;/p&gt;
&lt;p&gt;(Of course encapsulating the event firing in a common method as OnEvent() is also necessary when anything else than firing the event should be done)&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the class:&lt;/p&gt;&lt;pre&gt;public static class Fire
{
	public static object Event(Delegate theDelegate, params object[] args)
	{
		if (theDelegate != null)
			return theDelegate.DynamicInvoke(args);
		return null;
	}
}

&lt;/pre&gt;
&lt;p&gt;And here&amp;#39;s some code showing it off..&lt;/p&gt;&lt;pre&gt;// Forwarding &amp;quot;menu&amp;quot; click to presenter
protected void repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
	Fire.Event(NavigatingTo, this, new NavigatingEventArgs(e.Item.ItemIndex));
}

// Exposing event to derived classes
protected void OnViewInitialized()
{
	Fire.Event(ViewInitialized, this, EventArgs.Empty);
}

// Which is just a wee bit cooler than...
protected void OnViewInitialized()
{
	if (ViewInitialized != null)
		ViewInitialized(this, EventArgs.Empty);
}


&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=32" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Utilities/default.aspx">Utilities</category></item><item><title>Conditional formatting of System.Boolean</title><link>http://community.omnicom.no/blogs/lea/archive/2009/05/28/conditional-formatting-of-system-boolean.aspx</link><pubDate>Thu, 28 May 2009 11:38:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:31</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=31</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=31</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2009/05/28/conditional-formatting-of-system-boolean.aspx#comments</comments><description>&lt;p&gt;I had a small challenge today (yay!) when trying to localize some strings based on a boolean in the domain.&lt;/p&gt;
&lt;p&gt;Boolean&amp;#39;s ToString() methods only returns the static strings &amp;quot;True&amp;quot; and &amp;quot;False&amp;quot;, hence String.Format(MyLocalizedString, true) cannot return &amp;quot;ja&amp;quot;, &amp;quot;sant&amp;quot;, or any other norwegian representations of the bool true.&lt;/p&gt;
&lt;p&gt;Enter the FormattableBool&amp;nbsp;which interprets a&amp;nbsp;conditional operator in the format string. :)&lt;/p&gt;&lt;pre&gt;	public struct FormattableBool : IFormattable
	{
		static FormattableBool fbTrue = new FormattableBool(true);
		static FormattableBool fbFalse = new FormattableBool(false);

		bool value;

		public FormattableBool(bool value)
		{
			this.value = value;
		}

		#region IFormattable Members

		public string ToString(string format, IFormatProvider formatProvider)
		{
			if (format.StartsWith(&amp;quot;LC&amp;quot;))
			{
				if (!(format.Contains(&amp;quot;?&amp;quot;) &amp;amp;&amp;amp; format.Contains(&amp;quot;:&amp;quot;)))
					throw (new InvalidOperationException(&amp;quot;Format does not contain ? and :&amp;quot;));

				string[] formatParts = format.Split(&amp;quot;?:&amp;quot;.ToCharArray());
				if (formatParts.Length != 3)
					throw (new InvalidOperationException(&amp;quot;Format is invalid&amp;quot;));

				return value ? formatParts[1] : formatParts[2];
			}
			else
				return ToString();
		}

		#endregion

		public static implicit operator FormattableBool(bool x)
		{
			return x ? fbTrue : fbFalse;
		}

		public static explicit operator bool(FormattableBool x)
		{
			return x.value;
		}

		public override bool Equals(object obj)
		{
			if (obj is bool)
				return value.Equals(obj);
			if (obj is FormattableBool)
				return value.Equals(((FormattableBool)obj).value);
			return false;
		}

		public override int GetHashCode()
		{
			return value.GetHashCode();
		}
	}
&lt;/pre&gt;
&lt;p&gt;Turns out&amp;nbsp;it can be used in several forms, where my favorite must be (FormattableBool)true.&lt;/p&gt;&lt;pre&gt;	[TestMethod]
	public void TestFormattableBoolFormatting()
	{
		bool yep = true;
		bool nope = false;

		FormattableBool fyep = true;
		FormattableBool fnope = false;

		Assert.AreEqual(yep, fyep);
		Assert.AreEqual(nope, fnope);

		Assert.AreEqual(&amp;quot;ja&amp;quot;, String.Format(&amp;quot;{0:LC?ja:nei}&amp;quot;, fyep));
		Assert.AreEqual(&amp;quot;nei&amp;quot;, String.Format(&amp;quot;{0:LC?ja:nei}&amp;quot;, fnope));

		Assert.AreEqual(&amp;quot;yep&amp;quot;, String.Format(&amp;quot;{0:LC?yep:nope}&amp;quot;, (FormattableBool)true));
		Assert.AreEqual(&amp;quot;nope&amp;quot;, String.Format(&amp;quot;{0:LC?yep:nope}&amp;quot;, (FormattableBool)false));

	}

&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=31" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Utilities/default.aspx">Utilities</category></item><item><title>Road requirements for developers</title><link>http://community.omnicom.no/blogs/lea/archive/2009/03/02/road-requirements-for-developers.aspx</link><pubDate>Mon, 02 Mar 2009 07:49:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:30</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=30</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=30</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2009/03/02/road-requirements-for-developers.aspx#comments</comments><description>&lt;p&gt;I just read an article about norwegian organizations who&amp;nbsp;suggest a bunch of road requirements today. It struck me that they fit well with programming practices:&lt;/p&gt;
&lt;p&gt;&lt;span class="title"&gt;«The Peoples Road Requirements»&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1. Norway should have a good and uniform roadnet securing access for all. 
&lt;li&gt;2. The roads must be modelled so that human errors don&amp;#39;t get fatal consequences. 
&lt;li&gt;3. The&amp;nbsp;roads shall be maintained continously and repaired when not accoring to&amp;nbsp;fixed standard. 
&lt;li&gt;4. The roads must be developed so the negative impact&amp;nbsp;from traffic on the enviornment is as small as possible. 
&lt;li&gt;5. The roads shall have a standard fit for todays needs so it is possible to plan and carry out the journey as expected. 
&lt;li&gt;6. The road users are entitled to good and correct information about road- and snow conditions.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Source: &lt;a href="http://www.aftenposten.no/nyheter/iriks/article2954264.ece"&gt;http://www.aftenposten.no/nyheter/iriks/article2954264.ece&lt;/a&gt;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=30" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/practices/default.aspx">practices</category></item><item><title>Spreading common skin files for ASP.NET 2.0 to ease theme images</title><link>http://community.omnicom.no/blogs/lea/archive/2009/02/10/spreading-common-skin-files-for-asp-net-2-0-to-ease-theme-images.aspx</link><pubDate>Mon, 09 Feb 2009 16:22:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:29</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=29</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=29</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2009/02/10/spreading-common-skin-files-for-asp-net-2-0-to-ease-theme-images.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve been sure the ASP.NET theme framework fixed the url&amp;#39;s of pictures with equal paths under the application as the themes.&lt;br /&gt;Looks like it doesn&amp;#39;t. The only way to theme images is to have a skin file in each theme.&lt;/p&gt;
&lt;p&gt;Why would I want to duplicate SkinID=&amp;quot;thisImage&amp;quot; ImageUrl=&amp;quot;Images/ThisImage.gif&amp;quot; for all my themes if the images are named the same?&lt;/p&gt;
&lt;p&gt;The solution is batch files.&lt;/p&gt;
&lt;p&gt;Having the following bat file in my solution dir, I can spread a common skin file containing image urls to all my themes:&lt;/p&gt;&lt;pre&gt;for /f &amp;quot;delims=&amp;quot; %%i in (&amp;#39;dir &amp;quot;%~1App_Themes&amp;quot; /ad/b&amp;#39;) do copy &amp;quot;%~1App_Themes\Images.skin&amp;quot; &amp;quot;%~1\App_Themes\%%i\Images.skin&amp;quot;&lt;/pre&gt;
&lt;p&gt;now I just run &amp;quot;$(SolutionDir)\SpreadSkin.bat&amp;quot; &amp;quot;$(ProjectDir)&amp;quot; in my pre build even and I&amp;#39;ve got&amp;nbsp;the skin file in all theme folders. &lt;br /&gt;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=29" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Utilities/default.aspx">Utilities</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>URL Addressable Queue Views in CRM 4.0</title><link>http://community.omnicom.no/blogs/lea/archive/2009/01/27/url-addressable-queue-views-in-crm-4-0.aspx</link><pubDate>Tue, 27 Jan 2009 11:51:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:28</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=28</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=28</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2009/01/27/url-addressable-queue-views-in-crm-4-0.aspx#comments</comments><description>&lt;p&gt;I got the brilliant idea of displaying multiple queues today, and boldly stated it could be done easily with SharePoint and URL addressable views.&lt;/p&gt;
&lt;p&gt;Well, I was wrong, although the solution is quite simple.&lt;/p&gt;
&lt;p&gt;CRM Queues does not support URL addressing as is, so I had to create something.&lt;/p&gt;
&lt;p&gt;After poking around Microsoft.Crm.Web.dll a bit using Reflector, I found that the queue id of your personal queue is set during OnPreRender.&lt;br /&gt;So I made a copy of the /workplaces/home_workplace.aspx file calling it home_workplace_parameter.aspx, and inserted the following after the last &amp;lt;%@ Import %&amp;gt; statement:&lt;/p&gt;&lt;pre&gt;&amp;lt;script runat=&amp;quot;server&amp;quot; language=&amp;quot;C#&amp;quot;&amp;gt;

protected override void Render( HtmlTextWriter writer )
{

	this.crmGrid.Parameters.Set(&amp;quot;qid&amp;quot;, Request.QueryString[&amp;quot;qid&amp;quot;]);
	base.Render(writer);
}

&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;p&gt;I really hoped it would work, but it turns out CRM 4.0 validates querystring parameters. That can be remedied by adding a DWORD to the registry:&lt;br /&gt;&lt;u&gt;&lt;font color="#0000ff" size="2"&gt;&lt;a href="http://www.eggheadcafe.com/software/aspnet/31131911/crm-parameter-filter--in.aspx"&gt;http://www.eggheadcafe.com/software/aspnet/31131911/crm-parameter-filter--in.aspx&lt;/a&gt;&lt;br /&gt;&lt;/u&gt;&lt;/font&gt;(Add at HKEY_Local_Machine\Software\Microsoft\MSCRM - DWORD DisableParameterFilter = 1)&lt;/p&gt;
&lt;p&gt;Now I can go to &lt;a href="http://server/organization/workplace/home_workplace_parameter.aspx?qid={xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"&gt;http://&lt;em&gt;server/organization&lt;/em&gt;/&lt;u&gt;&lt;font color="#0066cc"&gt;workplace/home_workplace_parameter.aspx?qid={xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&lt;/a&gt;}&lt;/font&gt;&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;There are some script problems and other stuff I&amp;#39;d like to fix, but for now this works good enough. :)&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=28" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Microsoft+CRM/default.aspx">Microsoft CRM</category></item><item><title>Hello world from Python .Net</title><link>http://community.omnicom.no/blogs/lea/archive/2008/12/21/hello-world-from-python-net.aspx</link><pubDate>Sat, 20 Dec 2008 15:56:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:27</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=27</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=27</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/12/21/hello-world-from-python-net.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve had some fun with &lt;a class="" title="Python.Net" href="http://pythonnet.sourceforge.net/"&gt;Python.Net&lt;/a&gt; today. I&amp;#39;m sure we can find some use for python scripting some time.&lt;/p&gt;
&lt;p&gt;Stepped over a few stones to get a working example running, here&amp;#39;s a couple of points:&lt;/p&gt;
&lt;p&gt;- import CLR has to be stated to interact with .Net code&lt;br /&gt;- Strings passed to .Net has to be unicode&lt;br /&gt;- Why print doesn&amp;#39;t output to Console.Out is still a mystery&lt;/p&gt;
&lt;p&gt;And without further ado, here&amp;#39;s a Hello World app with a function, a variable and some .Net calls:&lt;/p&gt;&lt;pre&gt;using System;
using Python.Runtime;

namespace HelloWorld
{
	public class Program
	{
		static void Main(string[] args)
		{
			IntPtr gs;
			PythonEngine.Initialize();
            gs = PythonEngine.AcquireLock();

			try
			{
				int result = 
					PythonEngine.RunSimpleString(&amp;quot;&amp;quot;
						+ &amp;quot;import CLR\n&amp;quot;
						+ &amp;quot;from CLR.System import Console\n&amp;quot;
						+ &amp;quot;from time import time,ctime\n&amp;quot;
						+ &amp;quot;def GetHello():\n&amp;quot;
						+ &amp;quot;	return u&amp;#39;Having spam and eggs at &amp;#39; + unicode(ctime(time()))\n&amp;quot;
						+ &amp;quot;\n&amp;quot;
						+ &amp;quot;hello = GetHello()\n&amp;quot;
						+ &amp;quot;Console.WriteLine(hello)\n&amp;quot;
					);

				Console.WriteLine(result);
				
			}
			finally
			{
				PythonEngine.ReleaseLock(gs);
				PythonEngine.Shutdown();
			}

			Console.ReadKey();
		}
	}
}

&lt;/pre&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=27" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Scripting/default.aspx">Scripting</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Python/default.aspx">Python</category></item><item><title>File copy takes time...</title><link>http://community.omnicom.no/blogs/lea/archive/2008/12/08/file-copy-takes-time.aspx</link><pubDate>Mon, 08 Dec 2008 11:19:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:25</guid><dc:creator>lea</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=25</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=25</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/12/08/file-copy-takes-time.aspx#comments</comments><description>&lt;p&gt;Just had to post this hilarious reply from the IT department.&lt;/p&gt;
&lt;p&gt;My screen and the following comments over msn:&lt;/p&gt;
&lt;p&gt;&lt;img height="1" alt="" src="http://community.omnicom.no/blogs/lea/longtime.jpg" width="1" border="0" /&gt;&lt;img height="244" alt="" src="http://community.omnicom.no/blogs/lea/longtime.jpg" width="416" border="0" /&gt;&lt;/p&gt;&lt;font color="#545454" size="2"&gt;
&lt;p&gt;Lars-Erik says: (screen now says 40000 days)&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font face="MS Sans Serif" size="2"&gt;ok,&amp;nbsp;done copying in&amp;nbsp;109 years&lt;/p&gt;&lt;/font&gt;&lt;font color="#545454" size="2"&gt;
&lt;p&gt;Evert says:&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font size="2"&gt;I&amp;#39;ll notify my grandson &lt;/p&gt;&lt;/font&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=25" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/humor/default.aspx">humor</category></item><item><title>Entities as interfaces vs. Linq to Entities revisited and lost</title><link>http://community.omnicom.no/blogs/lea/archive/2008/11/26/entities-as-interfaces-vs-linq-to-entities-revisited-and-lost.aspx</link><pubDate>Tue, 25 Nov 2008 22:34:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:22</guid><dc:creator>lea</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=22</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=22</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/11/26/entities-as-interfaces-vs-linq-to-entities-revisited-and-lost.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;m following up on &lt;a class="" href="http://community.omnicom.no/blogs/lea/archive/2008/10/11/almost-there-but-no.aspx"&gt;that case&lt;/a&gt; here, still clinging to some hope:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4172128&amp;amp;SiteID=1&amp;amp;mode=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4172128&amp;amp;SiteID=1&amp;amp;mode=1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;(This is mostly educational, still under consideration for production use if you should wonder ;) )&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit 02 jan 2009&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Yet another hope stirring:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb738631.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb738631.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Gonna see what happens with the .Cast&amp;lt;&amp;gt;() method if I implement those interfaces on the entities instead of using an expression&amp;nbsp;visitor.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit 19 jan 2009&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And so he tossed away all the ideas about interfaces for entities as the POCO adapter for L2E arrives :)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/jkowalski/archive/2008/09/09/persistence-ignorance-poco-adapter-for-entity-framework-v1.aspx"&gt;http://blogs.msdn.com/jkowalski/archive/2008/09/09/persistence-ignorance-poco-adapter-for-entity-framework-v1.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks to Jimmy Nilsson&amp;nbsp;(&lt;a href="http://jimmynilsson.com/"&gt;http://jimmynilsson.com&lt;/a&gt;)&amp;nbsp;for the information.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=22" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/patterns/default.aspx">patterns</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Linq+to+Entities/default.aspx">Linq to Entities</category></item><item><title>Filtering Excel by cell color</title><link>http://community.omnicom.no/blogs/lea/archive/2008/10/28/filtering-excel-by-cell-color.aspx</link><pubDate>Tue, 28 Oct 2008 13:42:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:19</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=19</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=19</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/10/28/filtering-excel-by-cell-color.aspx#comments</comments><description>&lt;p&gt;I had the pleasure of getting a rather large pivoted list of numbers to import today, where of course the data to import were niftily marked with a green color.&lt;/p&gt;
&lt;p&gt;Of course I have my &amp;quot;convert pivoted stuff to tabluar data&amp;quot; macro ready, but I was unsure how to attack the problem of limiting my list to updated stuff (green rows).&lt;/p&gt;
&lt;p&gt;Luckily my mind was quicker than my need to do heavy lifting, so I came up with this nice little custom function:&lt;/p&gt;&lt;pre&gt;Public Function GetColor(ref As Range) As String
    Dim color As String
    color = Hex(ref.Cells(1, 1).Interior.color)
    GetColor = color &amp;amp; Replace(Space(6 - Len(color)), &amp;quot; &amp;quot;, &amp;quot;0&amp;quot;)
End Function
&lt;/pre&gt;
&lt;p&gt;With it, I could add a column with the following formula:&lt;/p&gt;
&lt;p&gt;=GetColor(Table1[[#This Row];[ColoredColumn]])&lt;/p&gt;
&lt;p&gt;Et&amp;nbsp;voilá, out comes a nicely formatted hexadecimal color for me to filter on:&lt;/p&gt;
&lt;p&gt;
&lt;table class="" style="WIDTH:199pt;BORDER-COLLAPSE:collapse;" cellspacing="0" cellpadding="0"&gt;




&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="xl63" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:white 0.5pt solid;BORDER-LEFT:#f0f0f0;WIDTH:151pt;BORDER-BOTTOM:white 0.5pt solid;HEIGHT:15pt;BACKGROUND-COLOR:#92d050;" class="xl63"&gt;&lt;font face="Calibri"&gt;Some data&lt;/font&gt;&lt;/td&gt;
&lt;td class="xl63" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:white 0.5pt solid;BORDER-LEFT:#f0f0f0;WIDTH:48pt;BORDER-BOTTOM:white 0.5pt solid;BACKGROUND-COLOR:#92d050;" class="xl63"&gt;&lt;font face="Calibri"&gt;50D092&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="" style="BORDER-RIGHT:#f0f0f0;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:#f0f0f0;HEIGHT:15pt;BACKGROUND-COLOR:transparent;"&gt;&lt;font face="Calibri"&gt;Some unformatted data&lt;/font&gt;&lt;/td&gt;
&lt;td class="" style="BORDER-RIGHT:#f0f0f0;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:#f0f0f0;BACKGROUND-COLOR:transparent;"&gt;&lt;font face="Calibri"&gt;FFFFFF&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="xl68" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:white 0.5pt solid;HEIGHT:15pt;BACKGROUND-COLOR:#92d050;" class="xl68"&gt;&lt;font face="Calibri"&gt;More formatted&lt;/font&gt;&lt;/td&gt;
&lt;td class="xl64" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:white 0.5pt solid;BACKGROUND-COLOR:#92d050;" class="xl64"&gt;&lt;font size="2"&gt;50D092&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="xl66" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:white 0.5pt solid;HEIGHT:15pt;BACKGROUND-COLOR:yellow;" class="xl66"&gt;&lt;font face="Calibri"&gt;Yellow data&lt;/font&gt;&lt;/td&gt;
&lt;td class="xl65" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:white 0.5pt solid;BACKGROUND-COLOR:yellow;" class="xl65"&gt;&lt;font face="Calibri"&gt;FFFF00&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="HEIGHT:15pt;"&gt;
&lt;td class="xl67" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:white 0.5pt solid;HEIGHT:15pt;BACKGROUND-COLOR:red;" class="xl67"&gt;&lt;font face="Calibri"&gt;And some red data&lt;/font&gt;&lt;/td&gt;
&lt;td class="xl67" style="BORDER-RIGHT:white 0.5pt solid;BORDER-TOP:#f0f0f0;BORDER-LEFT:#f0f0f0;BORDER-BOTTOM:white 0.5pt solid;BACKGROUND-COLOR:red;" class="xl67"&gt;&lt;font face="Calibri"&gt;FF0000&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;
&lt;p&gt;If you haven&amp;#39;t written custom Excel functions before, the trick is to put them in a module in the VBA project. Excel does not look for custom functions in ThisWorkbook or the Sheet&lt;em&gt;n&lt;/em&gt; classes.&lt;/p&gt;
&lt;p&gt;Of course, later in the day I found that filtering by color is a new feature in 2007. :P&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc952296.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc952296.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=19" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/VBA/default.aspx">VBA</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Excel/default.aspx">Excel</category></item><item><title>A little whining about the AJAX acronym</title><link>http://community.omnicom.no/blogs/lea/archive/2008/10/17/a-little-whining-about-the-ajax-acronym.aspx</link><pubDate>Thu, 16 Oct 2008 19:41:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:18</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=18</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=18</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/10/17/a-little-whining-about-the-ajax-acronym.aspx#comments</comments><description>&lt;p&gt;I thought of this the other day and wrote a post about it, but my browser crashed when I hit &amp;quot;publish&amp;quot;. Might have been a cosmic hint to think it through, but here goes again. :P&lt;/p&gt;
&lt;p&gt;To fix a long demanded requirement of uploading multiple files at once to our CMS tool, we finally came out with a Silverlight 2 control handling the issue. (Ended up rather nice :) )&lt;br /&gt;When I copied the .xap to a web app I was gonna use it in, put in a reference to the silverlight dll and referenced the assembly in my user control, the IDE promptly told me to include a scriptmanager too. All right, I thought, that&amp;#39;s reasonable.. But when I opened the toolbox to drag one out, I had to find it under the &amp;quot;AJAX&amp;quot; tab.&lt;/p&gt;
&lt;p&gt;Whatever happened to good old DHTML?&lt;/p&gt;
&lt;p&gt;There&amp;#39;s obviously no asynchronous operations when scripting creation of an object tag clientside, and there&amp;#39;s not much XML involved either (the contents of the .xap aside). So that leaves us with some HTML and some JavaScript modding the DOM.&lt;br /&gt;In the old days, that was DHTML.&lt;br /&gt;In the old days, I wrote AJAX without knowing it was AJAX using the Remote Scripting Java applet included in Visual InterDev 6.0. I even used Netscape and Access, but I was a devil with DHTML.&lt;/p&gt;
&lt;p&gt;Can we please put the hats where they ought to be again? ;)&lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=18" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/ranting/default.aspx">ranting</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/whining/default.aspx">whining</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/ajax/default.aspx">ajax</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/dhtml/default.aspx">dhtml</category></item><item><title>Prism and NSIS to the rescue</title><link>http://community.omnicom.no/blogs/lea/archive/2008/10/17/prism-and-nsis-to-the-rescue.aspx</link><pubDate>Thu, 16 Oct 2008 19:07:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:17</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=17</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=17</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/10/17/prism-and-nsis-to-the-rescue.aspx#comments</comments><description>&lt;p&gt;We got an urgent request today to help a client wrap an internal&amp;nbsp;web application in a custom FireFox browser with an accompagnying .msi installer. &lt;/p&gt;
&lt;p&gt;We started hacking along on a fresh 3.0.3 setup package, modding userchrome.css to remove menu items&amp;nbsp;and installing this and that extension. When I was half green in the face and complained loudly to a colleague who hadn&amp;#39;t listened to us, he just lit up and uttered &amp;quot;Prism&amp;quot; with a big grin. Saved my day! It&amp;#39;s a side project of Mozilla for a light-weight FF installation without any toolbars or other browser clutter. It just shows the web app, and that&amp;#39;s it.&lt;/p&gt;
&lt;p&gt;(Who at the FF team figured the help menu should be named #helpMenu, when file, edit etc. are #file-menu? And why is the history menu named #go-menu, when all other are equal? God bless Prism...)&lt;/p&gt;
&lt;p&gt;We didn&amp;#39;t accomplish the .msi installer, but at least we managed to produce a nice small installer using Nullsofts NSIS. Mostly because I found a more or less&amp;nbsp;finished NSIS&amp;nbsp;script for Prism, but also because it&amp;#39;s open source and free. And it supported silent install, and passed the customer&amp;#39;s policy. :P&lt;/p&gt;
&lt;p&gt;All in all, I&amp;#39;m rather happy about the result, and the&amp;nbsp;customer seems rather happy too. :)&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the resources:&lt;br /&gt;Prism: &lt;a href="http://labs.mozilla.com/projects/prism/"&gt;http://labs.mozilla.com/projects/prism/&lt;/a&gt;&lt;br /&gt;NSIS: &lt;a href="http://nsis.sourceforge.net/Main_Page"&gt;http://nsis.sourceforge.net/Main_Page&lt;/a&gt;&lt;br /&gt;NSIS Script (bottom of page): &lt;a href="http://labs.mozilla.com/forum/comments.php?DiscussionID=285"&gt;http://labs.mozilla.com/forum/comments.php?DiscussionID=285&lt;/a&gt;&lt;br /&gt;(Thanks to &amp;quot;royce&amp;quot; &lt;a href="https://labs.mozilla.com/forum/account.php?u=1963"&gt;https://labs.mozilla.com/forum/account.php?u=1963&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Shortened down and line-break fixed&amp;nbsp;NSIS script:&lt;/p&gt;&lt;pre&gt;;NSIS Modern User Interface 

;-------------------------------- 
; Start 

!include &amp;quot;MUI2.nsh&amp;quot; 

!define MUI_PRODUCT &amp;quot;Name of webapp&amp;quot; 
!define MUI_VERSION &amp;quot;&amp;quot; 
!define MUI_BRANDINGTEXT &amp;quot;Your company here&amp;quot; 
CRCCheck On 

;!include &amp;quot;${NSISDIR}\Contrib\Modern UI\System.nsh&amp;quot; 

;-------------------------------- 
;General 

;Name and file 
Name &amp;quot;Name of webapp&amp;quot; 
OutFile &amp;quot;setup.exe&amp;quot; 

;Default installation folder 
InstallDir &amp;quot;$PROGRAMFILES\Prism&amp;quot; 

;Get installation folder from registry if available 
InstallDirRegKey HKCU &amp;quot;Software\Prism&amp;quot; &amp;quot;&amp;quot; 

;Request application privileges for Windows Vista 
RequestExecutionLevel user 

;-------------------------------- 
;Interface Settings 

!define MUI_ABORTWARNING 
!define MUI_ICON &amp;quot;---PATH TO SETUP ICON HERE---&amp;quot;; There&amp;#39;s some in the NSIS folder
!define MUI_UNICON &amp;quot;---PATH TO SETUP ICON HERE---&amp;quot;
!define MUI_WELCOMEPAGE   
!define MUI_UNINSTALLER 
!define MUI_UNCONFIRMPAGE 
!define MUI_FINISHPAGE   

;Pages 

!insertmacro MUI_PAGE_WELCOME 
!insertmacro MUI_PAGE_INSTFILES 

# These indented statements modify settings for MUI_PAGE_FINISH 
!define MUI_FINISHPAGE_NOAUTOCLOSE 
!define MUI_FINISHPAGE_RUN 
!define MUI_FINISHPAGE_RUN_CHECKED 
!define MUI_FINISHPAGE_RUN_TEXT &amp;quot;Start -- YOUR APP NAME HERE --&amp;quot; 
!define MUI_FINISHPAGE_RUN_FUNCTION &amp;quot;LaunchLink&amp;quot; 

!insertmacro MUI_PAGE_FINISH		 


;-------------------------------- 
;Languages 

!insertmacro MUI_LANGUAGE &amp;quot;English&amp;quot; 

;--------------------------------  

;-------------------------------- 
;Installer Sections 

Section &amp;quot;Install Section&amp;quot; SecInstall 

;  set the context for $SMPROGRAMS and other shell folder to the &amp;#39;current&amp;#39; user 
SetShellVarContext current 

;  PRISM webApp data is recursively copied from yourAppAppData to &amp;quot;$APPDATA\WebApps&amp;quot; 
SetOutPath &amp;quot;$APPDATA\WebApps\-- YOUR PRISM APP NAME HERE --@prism.app\&amp;quot; 
File /r --- YOUR APPDATA FOLDER HERE --- \WebApps\-- YOUR PRISM APP NAME HERE --@prism.app\* 

;  PRISM application data is recursively copied from yourAppPgmFiles to &amp;quot;$APPDATA\yourApp\Prism&amp;quot; 
SetOutPath &amp;quot;$PROGRAMFILES\Prism&amp;quot; 
File /r C:\Program Files\Prism\*   

;windirExists: 
;Store installation folder 
WriteRegStr HKCU &amp;quot;Software\Prism&amp;quot; &amp;quot;&amp;quot; $INSTDIR 


;Create Shortcut links 
CreateShortcut &amp;quot;$DESKTOP\${MUI_PRODUCT}.lnk&amp;quot; &amp;quot;$PROGRAMFILES\Prism\prism.exe&amp;quot; &amp;quot;-override $\&amp;quot;$APPDATA\WebApps\-- YOUR PRISM APP NAME --@prism.app\override.ini$\&amp;quot; -webapp -- YOUR PRISM APP NAME --@prism.app&amp;quot; &amp;quot;$APPDATA\WebApps\-- YOUR PRISM APP NAME --@prism.app\icons\default\webapp.ico&amp;quot;

;Create uninstaller 
;write uninstall information to the registry 
WriteRegStr HKLM &amp;quot;Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}&amp;quot; &amp;quot;DisplayName&amp;quot; &amp;quot;${MUI_PRODUCT} (remove only)&amp;quot; 
WriteRegStr HKLM &amp;quot;Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}&amp;quot; &amp;quot;UninstallString&amp;quot; &amp;quot;$INSTDIR\Uninstall.exe&amp;quot;  
WriteUninstaller &amp;quot;$INSTDIR\Uninstall.exe&amp;quot; 


SectionEnd 

;-------------------------------- 
;Uninstaller Section 

Section &amp;quot;Uninstall&amp;quot; 

;  set the context for $SMPROGRAMS and other shell folder to the &amp;#39;current&amp;#39; user 
SetShellVarContext current 

;ADD YOUR OWN FILES HERE... 

Delete &amp;quot;$DESKTOP\${MUI_PRODUCT}.lnk&amp;quot;  
Delete &amp;quot;$INSTDIR\Uninstall.exe&amp;quot; 

;Delete Files  
RMDir /r &amp;quot;$INSTDIR\*.*&amp;quot;   

RMDir &amp;quot;$INSTDIR&amp;quot;   
RMDir &amp;quot;$PROGRAMFILES\Prism&amp;quot; 
RmDir &amp;quot;$APPDATA\WebApps\-- YOUR PRISM APP NAME --@prism.app&amp;quot; 

;Delete Uninstaller And Unistall Registry Entries 
DeleteRegKey HKEY_LOCAL_MACHINE &amp;quot;SOFTWARE\${MUI_PRODUCT}&amp;quot; 
DeleteRegKey HKEY_LOCAL_MACHINE &amp;quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}&amp;quot;   
DeleteRegKey /ifempty HKCU &amp;quot;Software\Prism&amp;quot; 

SectionEnd 


Function LaunchLink 
SetShellVarContext current	 

ExecShell &amp;quot;&amp;quot; &amp;quot;$DESKTOP\${MUI_PRODUCT}.lnk&amp;quot; 
FunctionEnd 

&lt;/pre&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=17" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/FireFox/default.aspx">FireFox</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Prism/default.aspx">Prism</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Deployment/default.aspx">Deployment</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/NSIS/default.aspx">NSIS</category></item><item><title>Eager loading with expand vs lazy loading with LoadProperty using ADO Data Services</title><link>http://community.omnicom.no/blogs/lea/archive/2008/10/13/when-ever-are-my-properties-done-loading.aspx</link><pubDate>Sun, 12 Oct 2008 17:45:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:16</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=16</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=16</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/10/13/when-ever-are-my-properties-done-loading.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;[Edit: The problem of eager-loading the stuff I ask for in expand&amp;nbsp;is solved]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t remember when first writing the code and this post that I&amp;#39;ve got a DataLoadOptions override in a custom context wrapped around the original Linq to SQL model. The Catalog/Items association in the example below is never eager-loaded, so of course I have to add a LoadWith(catalog =&amp;gt; catalog.Items) option on the innermost context&amp;#39;s DataLoadOptions. Now my .Expand(&amp;quot;Items&amp;quot;) call gives me a larger set of data and I&amp;#39;m most happy. Just feeling quite stupid not knowing my own API. :P&lt;/p&gt;The code now looks like the attractive:&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DataServiceQuery&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Catalog&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;gt; catalogQuery = context.Catalogs&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Expand(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Items/ItemFields/TemplateField&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Where(c =&amp;gt; c.ParentId == (&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)rootCatalogId) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DataServiceQuery&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Catalog&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;gt;;&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;catalogQuery.BeginExecute(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;delegate&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IAsyncResult&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; result)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catalogs = catalogQuery.EndExecute(result).ToList();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AllDone();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;The original solution was quite fun to write tho:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[Warning: See bolded text below]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been fiddling a bit with an ADO Data Service and the expand method. Can&amp;#39;t seem get it to work, or I don&amp;#39;t get to know when the associations are&amp;nbsp;loaded.&lt;/p&gt;
&lt;p&gt;So I started looking into LoadProperty, but Silverlight wants to call everything asynchronously, so if I loop in the callbacks, I just generate a lot more callbacks, and never know when the last one occurs.&lt;/p&gt;
&lt;p&gt;Enter the NotifyingStack. :P&lt;/p&gt;&lt;pre&gt;	public class NotifyingStack&amp;lt;T&amp;gt; : Stack&amp;lt;T&amp;gt;
	{
		public event EventHandler OnPopped;

		public NotifyingStack(EventHandler popped) : base()
		{
			OnPopped = popped;
		}

		public new T Pop()
		{
			T obj = base.Pop();
			if (OnPopped != null)
				OnPopped(this, EventArgs.Empty);
			return obj;
		}
	}
&lt;/pre&gt;
&lt;p&gt;Now I can do this:&lt;/p&gt;&lt;pre&gt;		private void PopulateSubCatalogsWithItems(object rootCatalogId)
		{
			DataServiceQuery&amp;lt;Catalog&amp;gt; catalogQuery = context.Catalogs
				.Expand(&amp;quot;Items/ItemFields&amp;quot;)
				.Where(c =&amp;gt; c.ParentId == (int)rootCatalogId) as DataServiceQuery&amp;lt;Catalog&amp;gt;;

			justAStack = new NotifyingStack&amp;lt;object&amp;gt;(new EventHandler(OnPop));
			justAStack.Push(null);
			catalogQuery.BeginExecute(
				delegate(IAsyncResult catalogQueryResult)
				{
					IEnumerable&amp;lt;Catalog&amp;gt; catalogResult = catalogQuery.EndExecute(catalogQueryResult);
					catalogs = catalogResult.ToList();
					foreach (Catalog catalog in catalogs)
					{
						justAStack.Push(null);
						context.BeginLoadProperty(catalog, &amp;quot;Items&amp;quot;,
							delegate(IAsyncResult itemQueryResult)
							{
								IEnumerable&amp;lt;Item&amp;gt; items = syzwebContext.EndLoadProperty(itemQueryResult).Cast&amp;lt;Item&amp;gt;();
								foreach (Item item in items)
								{
									justAStack.Push(null);
									syzwebContext.BeginLoadProperty(item, &amp;quot;ItemFields&amp;quot;,
										delegate(IAsyncResult itemFieldResult)
										{
											syzwebContext.EndLoadProperty(itemFieldResult);
											justAStack.Pop();
										}, null);
								}
								justAStack.Pop();
							}, null);
					}
					justAStack.Pop();
				}
				, catalogQuery);
			
		}

		private void OnPop(object sender, EventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(justAStack.Count);
			if (justAStack.Count == 0)
			{
				AllDone();
			}
		}
&lt;/pre&gt;
&lt;p&gt;I was first experimenting with a timer checking&amp;nbsp;a regular stack, but when trying to add stuff to the UserControl, Silverlight threw a cross threading exception.&lt;/p&gt;
&lt;p&gt;In this case, the event handler is in the right thread, and as long as I&amp;#39;m diciplined with the pushing and popping, the AllDone method will only be called once when all the data is loaded. :)&lt;/p&gt;
&lt;p&gt;Now, if anyone have a good laugh because you know how to get the expand method to instruct the BeginExecute method to get a big package, ie. by altering the server side service, please gimme a comment. (I&amp;#39;ve been looking at the xml from the ADO Service, and it only generates&amp;nbsp;urls to the data&amp;nbsp;for the expanded properties)&lt;/p&gt;
&lt;p&gt;Turns out though, I need a lot more than the stuff I got so far. So I have to keep this little trick up my sleave for something else. &lt;strong&gt;This&lt;/strong&gt; &lt;strong&gt;method would create about a 100 small chatty calls to the server before done&lt;/strong&gt;, hence I&amp;#39;m gonna &lt;strong&gt;[Edit: Remember my DataLoadOptions in the future]&lt;/strong&gt;. :)&lt;/p&gt;
&lt;p&gt;(But it was real fun doing it)&lt;/p&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=16" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/ADO+Data+Services/default.aspx">ADO Data Services</category></item><item><title>Entities as interfaces with Silverlight</title><link>http://community.omnicom.no/blogs/lea/archive/2008/10/12/entities-as-interfaces-with-silverlight.aspx</link><pubDate>Sun, 12 Oct 2008 12:58:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:15</guid><dc:creator>lea</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=15</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=15</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/10/12/entities-as-interfaces-with-silverlight.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;[Edit: This post&amp;nbsp;is a continuation of &lt;/strong&gt;&lt;a class="" href="http://community.omnicom.no/blogs/lea/archive/2008/10/11/embracing-it-all.aspx"&gt;&lt;strong&gt;this post&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;. The latter contains some links to some of the code used.&amp;nbsp;For instance&amp;nbsp;VarianceWorkaround]&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It didn&amp;#39;t actually turn out quite as I had hoped, (the&amp;nbsp;DataServiceQuery don&amp;#39;t know&amp;nbsp;how to translate&amp;nbsp;interface queries to URL queries)&amp;nbsp;but at least I&amp;#39;m able to write code such as this:&lt;/p&gt;&lt;pre&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt;&lt;font color="#0000ff"&gt; void&lt;/font&gt; userControl_Loaded(&lt;font color="#0000ff"&gt;object&lt;/font&gt; sender, &lt;font color="#2b91af"&gt;RoutedEventArgs&lt;/font&gt; e)
{
	&lt;font color="#2b91af"&gt;IQueryable&lt;/font&gt;projectQuery = 
		context.Project
		.Expand(&lt;font color="#a31515"&gt;&amp;quot;ProjectEntries&amp;quot;&lt;/font&gt;)
		.Where(p =&amp;gt; p.Name.Contains(&lt;font color="#a31515"&gt;&amp;quot;project&amp;quot;&lt;/font&gt;))
		.Skip(1)
		.Take(2);
	context.BeginExecute(&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;font color="#2b91af"&gt;AsyncCallback&lt;/font&gt;(GotResult), projectQuery);
}&lt;br /&gt;
&lt;font color="#0000ff"&gt;protected void&lt;/font&gt; GotResult(&lt;font color="#2b91af"&gt;IAsyncResult&lt;/font&gt; result)
{
	&lt;font color="#2b91af"&gt;IList&lt;/font&gt;&amp;lt;Model.&lt;font color="#2b91af"&gt;Project&lt;/font&gt;&amp;gt; projects = context.EndExecuteAsList&amp;lt;Model.&lt;font color="#2b91af"&gt;Project&lt;/font&gt;&amp;gt;(result);
}
&lt;/pre&gt;
&lt;p&gt;I generated a proxy for an ADO Data Service using the Entity Model created for my previous posts as described here:&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc794279.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc794279.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then hooked up all the interfaces on the generated entities&amp;nbsp;and created these two methods on the datacontext:&lt;/p&gt;&lt;font face="courier new, mono"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; BeginExecute(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;AsyncCallback&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; callback, &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; queryable)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryable.GetType().GetMethod(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;BeginExecute&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).Invoke(queryable,&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { callback, queryable });&lt;br /&gt;}&lt;/font&gt; &lt;br /&gt;&lt;br /&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IList&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt; EndExecuteAsList&amp;lt;T&amp;gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IAsyncResult&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; result) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; T : Model.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;OPWObject&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataServiceQuery&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; query = result.AsyncState &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Data.Services.Client.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DataServiceQuery&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; elementType = query.ElementType;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Reflection.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; toListGenericMethod = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Enumerable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).GetMethod(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;ToList&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.MakeGenericMethod(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { elementType });&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Data.Services.Client.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;QueryOperationResponse&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; queryResponse = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.GetType().GetMethod(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;EndExecute&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).Invoke(result.AsyncState, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { result })&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Data.Services.Client.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;QueryOperationResponse&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Collections.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IList&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; list = toListGenericMethod.Invoke(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { queryResponse })&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Collections.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IList&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Reflection.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; listConvertMethod = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;foreach&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (System.Reflection.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; method &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;in&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;VarianceWorkaround&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).GetMethods())&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (method.ReturnType.Name == &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;IList`1&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;listConvertMethod = method;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;break&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Reflection.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; genericListConvert = listConvertMethod.MakeGenericMethod(&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { elementType, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(T) }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;IList&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt; retVal = genericListConvert.Invoke(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { list }) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IList&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt;;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; retVal;&lt;br /&gt;}&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p&gt;I believe my main concern is to use&amp;nbsp;lists of the&amp;nbsp;interfaces in my UI logic.&amp;nbsp;So as long as I can rely on intellitip in the queries without referencing the &amp;quot;real&amp;quot; type, I&amp;#39;m where I want to be. :)&lt;/p&gt;
&lt;p&gt;Of course I need to have some kind of factory method to create instances of the entities, but that&amp;#39;s a small sacrifice.&lt;/p&gt;
&lt;p&gt;I do wonder though; as I discovered the EndExecute method of the context itself and not just on the DataServiceQueries when I was done;&amp;nbsp;whether my code could be considerably shorter... &lt;/p&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=15" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/patterns/default.aspx">patterns</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Almost there, but no</title><link>http://community.omnicom.no/blogs/lea/archive/2008/10/11/almost-there-but-no.aspx</link><pubDate>Sat, 11 Oct 2008 10:38:00 GMT</pubDate><guid isPermaLink="false">3b1c6479-3122-46fc-83fa-a7453145d0f4:12</guid><dc:creator>lea</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/rsscomments.aspx?PostID=12</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.omnicom.no/blogs/lea/commentapi.aspx?PostID=12</wfw:comment><comments>http://community.omnicom.no/blogs/lea/archive/2008/10/11/almost-there-but-no.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;[Edit: Once again, I revisit this one, and it&amp;#39;s probably still flawed as h***]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I guess the VarianceWorkaround posted&amp;nbsp;here will give you the complete table contents before filtering based on the interface properties. At least that&amp;#39;s what happens when using L2S.&lt;/p&gt;
&lt;p&gt;Some day soon I&amp;#39;ll hopefully manage to create either an ExpressionTreeVisitor to translate, or find or be told a better solution.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[Edit: I leave my original ramblings without the accusations.. see my solution further down. :) ]&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was &lt;a class="" href="http://community.omnicom.no/blogs/lea/archive/2008/10/11/embracing-it-all.aspx"&gt;almost there&lt;/a&gt; yesterday, but when I finnaly got all the lines right and ran my test, [Edit]I had probably sat for too long[/Edit].&lt;/p&gt;
&lt;p&gt;The following attempt at a repository for ADO.NET Entities throws a sad exception. Anyone?&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt; Repository&amp;lt;T&amp;gt;() &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; T : &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;global&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;::MyNamespace.IEntityInterface&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;EdmType&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; theType = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; types.Where(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;t =&amp;gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.GetType(t.FullName).GetInterface(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(T).FullName) != &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;).FirstOrDefault();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; entityType = &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.GetType(theType.FullName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; createQuery = internalContext.GetType().GetMethod(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;CreateQuery&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).MakeGenericMethod(entityType);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] parameters = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { theType.Name, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Data.Objects.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;ObjectParameter&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[0] };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; queryable = createQuery.Invoke(internalContext, parameters) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (queryable != &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; ((&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)queryable).Cast&amp;lt;T&amp;gt;(); // Throws the baddie&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;Throws the following:&lt;/p&gt;
&lt;p&gt;System.NotSupportedException: Unable to cast the type &amp;#39;EntityImpl&amp;#39; to type &amp;#39;IEntityInterface&amp;#39;. LINQ to Entities only supports casting Entity Data Model primitive types..&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[Edit: And here&amp;#39;s how my week-end might turn out to include time with my&amp;nbsp;better half&amp;nbsp;after all... :P]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Turns out I&amp;#39;d already posted the answer to my casting woes in my original post. The generics variance wrapper can at least convert enumerables of implemetations to their respective interfaces. Of course this demands dicipline when using (not casting birds as seagulls etc.), but at least I was able to query against the interface. And that&amp;#39;s a huge step forward!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m gonna dive into the VarianceWorkaround class sometime and see if I can&amp;#39;t make it fix IQueryables too.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the working repository method:&lt;br /&gt;(If anyone has any tips on how to get rid of the reflection mess, feel free to come forward)&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IEnumerable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt; Repository&amp;lt;T&amp;gt;() &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;where&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; T : &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;global&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;::&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IEntity&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;// LTE type for source type&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;EdmType&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; theType =&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; types.Where(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t =&amp;gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.GetType(t.FullName).GetInterface(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(T).FullName) != &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).FirstOrDefault();&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;// Source type&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; entityType = &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.GetType(theType.FullName);&lt;/p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;// Get create query method&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; createQuery = internalContext.GetType().GetMethod(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;CreateQuery&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).MakeGenericMethod(entityType);&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] parameters = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { theType.Name, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Data.Objects.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;ObjectParameter&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[0] };&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;// Get queryable&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; queryable = createQuery.Invoke(internalContext, parameters) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IQueryable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (queryable != &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;// source&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; enumerableType = &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.GetType(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;System.Collections.Generic.IEnumerable`1&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;// Find enumerable override of convert (find better way..?)&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; enumerableConvert = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;foreach&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; method &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;in&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;VarianceWorkaround&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;).GetMethods())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (method.ReturnType.Name == enumerableType.Name)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; enumerableConvert = method;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;break&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;// Get typed version of the convert method&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MethodInfo&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; genericEnumerableConvert = enumerableConvert.MakeGenericMethod(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Type&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { entityType, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(T) }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;// Cast the objectquery as IEnumerable&amp;lt;T&amp;gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IEnumerable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt; retVal = genericEnumerableConvert.Invoke(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[] { queryable }) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IEnumerable&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;T&amp;gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; retVal;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;else&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;null&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;}&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://community.omnicom.no/aggbug.aspx?PostID=12" width="1" height="1"&gt;</description><category domain="http://community.omnicom.no/blogs/lea/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://community.omnicom.no/blogs/lea/archive/tags/patterns/default.aspx">patterns</category></item></channel></rss>