LINQ Dynamic Query – Strongly Typed Way

 

In .NET 3.5 there is a System.Linq.Dynamic namespace which allows you to use string expressions in LINQ queries. It can be used to create dynamic queries but I don’t like it because it is not type-safe. So let me give you an introduction to anonymous functions, lambda expression trees and the PredicateBuilder class. These features can be used to create finder methods which can use dynamic strong-typed where-clauses as input parameters.

Via SCIP.be – Articles : .NET – LINQ to SQL – part 4

LINQ Dynamic Query Library

 

Example

Instead of using language operators or type-safe lambda extension methods to construct your LINQ queries, the dynamic query library provides you with string based extension methods that you can pass any string expression into.

For example,

Using the LINQ DynamicQuery library I could re-write the above query expression instead like so:

Notice how the conditional-where clause and sort-orderby clause now take string expressions instead of code expressions.  Because they are late-bound strings I can dynamically construct them.  For example: I could provide UI to an end-user business analyst using my application that enables them to construct queries on their own (including arbitrary conditional clauses).

Download Dynamic Query Library & Documentation

C# Dynamic Query Library (included in the \LinqSamples\DynamicQuery directory)

You can copy/paste either the C# or VB implementations of the DynamicQuery library into your own projects and then use it where appropriate to more dynamically construct LINQ queries based on end-user input.

Via Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) – ScottGu’s Blog

Building OAuth channel for WCF RESTful services

 

What is OAuth?

While OpenID and WS-Federation focus on delegating user identity (or a collection of identity claims), OAuth was designed to address a different and complementary scenario, the delegation of user authorization. In few words, OAuth allows a client application to obtain user consent (i.e. Authorization for consuming a private resource as access tokens) for executing operations over private resources on his behalf.

If you want to know more about how OAuth works, you should read the following posts

OAuth .NET Library

Alex Henderson (Aka Bittercoder) has written a pretty good OAuth library in .NET for implementing an OAuth consumer and service provider. The library is available here under a MIT license (do wherever you want with it), and it is very easy to use. Alex has definitively made a very good work.

OAuth WCF Channel using REST Starter Kit’s RequestInterceptor

WCF channel implementation for OAuth mounts on top of his library and it basically transforms a OAuth token into a .NET security principal that can be used later within the service implementation. The channel is implemented as a RequestInterceptor, one of new features introduced in the REST WCF Starter Kit. This interceptor basically captures the request at channel level and performs all the validations required by OAuth. The following sample illustrates how the interceptors can be plugged into an existing service host (service.svc),

Samples here: OAuth channel for WCF RESTful services – Pablo M. Cibraro (aka Cibrax)

Wix# (WixSharp) – managed interface for WiX

 

Wix# (WixSharp) – managed interface for WiX

By Oleg Shilo

This article describes Wix# (WixSharp), a managed interface to WiX (Windows Installer XML toolset for building Windows installation packages from the XML source code). Wix# allows building a complete MSI or WiX source code by using script files written with the C# syntax. It uses a C# class structure to mimic WiX entities and their relationships in order to produce a valid deployment model.

Diagrams showing MSI Deployment with Visual Studio and directly with WiX

image

image

 

Wix# Overview

The Wix# concept is quite simple. The Wix# source file is an ordinary C# file containing code defining relationships between instances of Wix# classes. Wix# classes represent deployment entities: files, shortcuts, registry values etc. The Wix# source file can be translated by the Wix# engine into the WiX source file, which then (optionally) can be automatically compiled into MSI. 

Sample:

Script for installing MyApp.exe into <ProgramFiles>\My Company\My Product directory; showing a custom license file; creating shortcuts to Install/Uninstall the product and to launch MyApp.exe from <Desktop> and <ProgramMenu>:

using System;

class Script
{
    static public void Main(string[] args)
    {
        var project = new WProject(“MyProduct”,
                          new WDir(@”%ProgramFiles%\My Company\My Product”,
                              new WFile(@”Files\Bin\MyApp.exe”,
                                  new WShortcut(@”%ProgramMenu%\My Company\My Product”),
                                  new WShortcut(@”%Desktop%”)),
                              new WShortcut(“Uninstall MyApp”, “[System64Folder]msiexec.exe”, “/x [ProductCode]”)),
                          new WDir(@”%ProgramMenu%\My Company\My Product”,
                              new WShortcut(“Uninstall MyApp”, “[System64Folder]msiexec.exe”, “/x [ProductCode]”))));
       project.Id = new Guid(“6f330b47-2577-43ad-9095-1861ba25889b”);
       project.LicenceFile = @”AppFiles\License.rtf”;
       WCompiler.BuildMsi(project); }
}

Via CodeProject: Wix# (WixSharp) – managed interface for WiX. Free source code and programming help

Small Basic

 

SmallBasic

Small Basic is a project that’s aimed at bringing “fun” back to programming. By providing a small and easy to learn programming language in a friendly and inviting development environment, Small Basic makes programming a breeze. Ideal for kids and adults alike, Small Basic helps beginners take the first step into the wonderful world of programming.

  • Small Basic derives its inspiration from the original BASIC programming language, and is based on the Microsoft .Net platform. It is really small with just 15 keywords and uses minimal concepts to keep the barrier to entry as low as possible.
  • The Small Basic development environment is simple, yet provides powerful modern environment features like Intellisenseā„¢ and instant context sensitive help.
  • Small Basic allows third-party libraries to be plugged in with ease, making it possible for the community to extend the experience in fun and interesting ways.

Getting Started Guide

Forums

FAQ

Small Basic Blog

Samples

Microsoft Small Basic aims to make computer programming accessible to beginners.

Download

Getting Started

  1. Download and install Small Basic
  2. Follow the Getting Started guide (docx or pdf) to build your first application