- Recent
- Popular
- Tags (0)
- Subscribers (1)
- C# 3.0: Invoke On WinForm Conrols easily with Lambda expressions (or anonymous methods)February 22
-
I really like Extension methods... especially when you combine them with other good language bits to really make a difficult problem a lot easier. I think invoking on Windows Forms applications is one of those problems that is elegantly solved by some of these new features. For an in-depth background on the 'whys' and details of having to use Invoke to access GUI elements from other threads in your windows forms applications, see this article.
I have always found stopping to Invoke something to be a bit of a pain - just enough effort to derail my train of thought while working on a WinForms applications. So back in the 1.1 days, I created some helper code to try to smooth this process out a bit. On method to help out invoke was called like this:
string value = InvokeHelper.GetProperty(myTextBox, "Text");
This was an improvement on invoking without help, but essentially all I was doing was wrapping some reflection calls to coax the value from the Text property.
Now, with extention methods, lambda expressions and the ability of the compiler to infer the resolution of generic type parameters to actual types, I was able to refactor many helper methods (variations on the above for getting and setting properties, fields, calling methods, and their overloads into two methods, this is the first:
public static TResult Invoke<T, TResult>(this T controlToInvo
- Microsoft Dynamics CRM Web Services: How to join entities to filter QueryExpression resultsJune 7 2007
-
There just isn't much information out there about Microsoft Dynamics CRM Web Services... at least not when compared to other technologies. And with Silverlight and Surface and PopFly burning up the MS blogosphere, it's kind of understandable.
Still, there are those of us who need to get things done in Microsoft Dynamics CRM... and so here's my little contribution.
It's probably not obvious what I was trying to accomplish from the title of this post. It's very simple, though. Let's say I want to get a list of customers from the CRM filtered by criteria in a table that is several 'joins' away. So in SQL using the sample AdventureWorks DB it looks like this:
SELECT * FROM Sales.Customer c
INNER JOIN Sales.CustomerAddress ca
ON c.CustomerId = ca.CustomerId
INNER JOIN Person.Address a
ON ca.AddressId = a.AddressId
WHERE City = 'Montreal'So now my CRM Web Services goal is more clear. I had this requirement and there wasn't much I could find about doing it, but I managed to cobble together this sample. Keep in mind the code I'm going to show you is *not* representative of our CRM or its custom fields, it's just how you would do it, mirroring the AdventureWorks SQL snippet above.
First thing I found handy was
- Super easy SQL Server 2005 Database Schema change auditingJune 4 2007
-
I love the xml type in SQL Server 2005. Here's a very simple way I made use of it: I audit all the object/schema changes to the database with a simple database-level trigger.
First, I create a very simple table (inside a schema I name 'Audit'):
CREATE TABLE [Audit].[Objects](
[EventID] [int] IDENTITY(1,1) NOT NULL,
[EventData] [xml] NULL,PRIMARY KEY CLUSTERED
(
[EventID] ASC
) WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]Then, the trigger:
CREATE TRIGGER [Trig_AuditObjects]
ON DATABASE
FOR DDL_DATABASE_LEVEL_EVENTS
AS
INSERT INTO Audit.Objects(EventData)
SELECT EVENTDATA()
GO
ENABLE TRIGGER [Trig_AuditObjects] ON DATABASEThat's it.. now I get a nice neat little xml entry in my table every time a DDL database level event happens, like so:
<EVENT_INSTANCE>
<EventType>ALTER_TABLE</EventType>
<PostTime>2007-06-03T20:12:05.813</PostTime>
<SPID>55</SPID>
<ServerName>CHI100906</ServerName>
<LoginName>MYDOMAIN\myusername</LoginName>
<UserName>dbo</UserName>
<DatabaseName>Sales</DatabaseName>
<SchemaName>dbo</SchemaName>
<ObjectName>Products</ObjectName>
<ObjectType>TABLE</ObjectType>
<TS - SQL Server 2005 XQuery does not implement XQuery 1.0 / XPath 2.0 fullyMay 30 2007
-
A coworker of mine was trying to apply the XPath 2.0 upper-case() function to some shredded xml from a query in SQL Server 2005 and inquired about it with me just before heading out the door.
Here's what's happening: You try to apply the upper-case function (that exists in the XQuery 1.0 / XPath 2.0 standard) to, say, the result from a .value() method call on some stored xml and you get this lovely message:
Msg 2395, Level 16, State 1, Line 4
XQuery [value()]: There is no function '{http://www.w3.org/2004/07/xpath-functions}:upper-case()'
And turns out it's not lying.... per Michael Rys in this post on microsoft.public.sqlserver.xml the standard is not fully implemented (even though it refers to it in the error message, and browsing http://www.w3.org/2004/07/xpath-functions does show upper-case() as a function). But SQL Server only supports:
- Mashups of the mp3 KindMay 16 2007
-
Well, I finally brought my first career (recording engineer) together with my love of the pop-culture phenom of mashups to release my first mashup to the world:
Unbelievable Disco Lolita Tale to Tale
That's Alizée's international hit "Moi Lolita" with overdubs of Love and Rocket's "No New Tale to Tell", U2's "Discothèque" and EMF's "Unbelievable".
It was fun to do, but I'm not sure I'll have much time to do more - in the meantime, hope you like it.
