Dec 152009
 

Sorry guys, but this is a super last minute event from HackerspaceSG which we just got word from Johannes Grenzfurthner yesterday of his intention to rant with us about his experience with context hacking.

For those who are unfamiliar with the rant: it is a tradition of performance art which was developed in Europe in the 19th century and successfully ported to the Internet in the early-to-mid 1990s. It is now being introduced to Asia by aesthetic pioneers like Johannes Grenzfurthner.

In recognition of Singapore’s leading position as the financial and cultural capital of Asia, and of Hackerspace.SG as the leading hackerspace in Singapore, he has chosen Hackerspace.SG as the venue for his first Singapore performance of this artwork.

We invite all members of Hackerspace.SG and the related community to attend this rant.

There is no fee, though we wish to thank in advance all the wonderful people who consume beer, wine, or soft drinks, for their cash donations into the little glass that says “your donations are welcome.”

For the purposes of licensing under Chapter 257 Section 319, this is an exempt entertainment as defined by the Public Entertainments and Meetings (Specified Arts Entertainment) (Exemption) Order 2005.

Details follow.

monochrom and the East: Some stories about Context Hacking and Asia
A tour-de-farce by Johannes Grenzfurthner of monochrom

monochrom is a worldwide operating collective dealing with technology, art and philosophy and was founded in 1993. So to sum up, monochrom is an unpeculiar mixture of proto-aesthetic fringe work, pop attitude, subcultural science, political activism and technological disaster.

Johannes wants to tell us stories about monochrom’s “context hacking” projects that specifically deal with our focus on contemporary Asian topics.

The term context hacking—like its mimetic sibling “communication guerrilla”—refers to unconventional forms of communication and/or intervention in more conventional processes of communication. Context hacking is a specific style of political action that observes and makes visible the paradoxes and absurdities of power. Context hacking uses absurdities as the starting point for interventions by playing with representations and identities, with alienation and over-identification.

Dec 152009
 

I thought I’ll post this in case anyone else encounters this problem. The purpose of the method is to get back a set of ClientContacts filtering based on the ClientID and select only those active if the onlyActive parameter is true, else ignore the IsActive filter and return all the records.

Here’s my LINQ query with a simple if-else shortcut within it:

[sourcecode language="csharp" highlight="5"]
public IQueryable<ClientContact> GetClientContactByClient(int clientID, bool onlyActive)
{
return from clientContact in this.db.ClientContacts
where clientContact.Client_AutoID == clientID &&
onlyActive ? clientContact.IsActive : true
select clientContact;
}
[/sourcecode]

Notice line 5? Here’s where I got this code wrong. The above code generates the following SQL statement:

[sourcecode language="sql"]
SELECT *
FROM [dbo].[ClientContacts] AS [t0]
WHERE (
(CASE
WHEN [t0].[Client_AutoID] = @p0 THEN CONVERT(Int,[t0].[IsActive])
ELSE @p1
END)) = 1
[/sourcecode]

If you actually work it out, this SQL statement will always return all records.

Here’s the change I made on the code to fix it.

[sourcecode language="csharp" highlight="5"]
public IQueryable<ClientContact> GetClientContactByClient(int clientID, bool onlyActive)
{
return from clientContact in this.db.ClientContacts
where clientContact.Client_AutoID == clientID &&
(onlyActive ? clientContact.IsActive : true)
select clientContact;
}
[/sourcecode]

Notice the brackets I added? This resulted in the generation of the following SQL statement:

[sourcecode language="sql"]
SELECT *
FROM [dbo].[ClientContacts] AS [t0]
WHERE ([t0].[Client_AutoID] = @p0) AND ((
(CASE
WHEN @p1 = 1 THEN CONVERT(Int,[t0].[IsActive])
ELSE @p2
END)) = 1)
[/sourcecode]

Again, if you work it out, this is the correct SQL statement to achieve what I want. I didn’t know a set of brackets make such a huge difference in the SQL code generation. Do take note of this when you’re finding out why your LINQ query doesn’t work as you might have thought.