Archive for the 'Did you know?' Category

LINQ to SQL for SQL Compact Edition - Did you know?

You can’t actually drag and drop a SQL Compact Edition 3.5 database to the LINQ to SQL designer. But it is very easy to create the classes and work beautifully. Fire up a VS08 prompt and find the SDF file that your database is stored in, then run the following command:

Prompt: SqlMetal /code:DotNetBooksDB.cs /pluralize /namespace:Books.Client.Library.Store.SqlCe dotNetBooks.sdf
Microsoft (R) Database Mapping Generator 2008 version 1.00.21022
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

The parameters are simple.

/code = the path where you would like to save the generated code.

/pluralize = changes the table book into books so you can write code like this: var x = from b in _ctx.Books (just looks a bit nicer)

/namespace = which namespace would you like your classes to have

and finally the path to the sdf file.

There is no output, but if you run the command your csharp should have been generated and just include that file into your project (and switch the project to .net Framework 3.5).

Powershell - Quick Tip #1: Run a .ps1 file

This is an egoistic post, but I need to remember this piece of information, so I’ll put it in a place I’m sure I’ll find it again. I might do that a little more often if my Google searches take too long (or my memory fails more often).

The problem: How do I run a .ps1 file (Powershell script) from within Powershell?

Attempt 1:

PS C:foo> .Install.ps1
File C:fooInstall.ps1 cannot be loaded. The file C:fooInstall.ps1 is
not digitally signed. The script will not execute on the system. Please
see "get-help about_signing" for more details..
At line:1 char:13
+ .Install.ps1 <<<<

Ok, strange but secure. How do you switch it off?

Read here for the details or continue for the summary:

The command “Get-ExecutionPolicy” will return the policy you are currently running with.

There are three options for the execution policy that you can set:

  • AllSigned (default): all scripts need to be signed.
  • RemoteSigned: Only scripts downloaded from the internet must be signed.
  • Unrestricted: Any scripts will run without being signed.

I changed the policy using “Set-ExecutionPolicy RemoteSigned” and voila…


Subscribe / Search

Imagine Cup 2009 - Egypt
msplogo_small.jpg
mcprgb.png

 

July 2008
M T W T F S S
« Jun    
 123456
78910111213
14151617181920
21222324252627
28293031  

Blog Stats

  • 10,824 hits