Archives for the '.NET' Category
Calling an Oracle stored procedure using NHibernate
The stored procedure must have an out sys_refcursor parameter as the first argument.
Tested with NHibernate 2.1.2 and Oracle 11g.
Needs Oracle.DataAccess (not System.Data.OracleClient). Tested with Oracle.DataAccess 2.111.6.0 AMD64.
NHibernate config:
<hibernate-configuration xmlns=”urn:nhibernate-configuration-2.2″>
<session-factory>
<property name=”connection.driver_class”>
NHibernate.Driver.OracleDataClientDriver
</property>
</session-factory>
</hibernate-configuration>
NHibernate mapping:
<hibernate-mapping xmlns=”urn:nhibernate-mapping-2.2″ assembly=”SampleProject” namespace=”SampleProject”>
<sql-query name=”GetEmployeesByDepartmentId”>
[…]
LINQPad – a worthy successor to Snippet Compiler
In 2009 I blogged about how Snippet Compiler allows us to test out C# code without having to create a project in Visual Studio just for that. Now there’s something better: LINQPad. Don’t be misled by its name; it’s not just for LINQ, it can run any C#, VB, or even SQL code. I particularly […]
Implementing the right-click context menu in Silverlight 4
Download and install Silverlight 4 Toolkit - April 2010.
In your Silverlight 4 project, add references to:
System.Windows.Controls
System.Windows.Controls.Input.Toolkit
In your UserControl XAML, add the following to the LayoutRoot grid opening tag: MouseRightButtonDown=”LayoutRoot_MouseRightButtonDown” MouseRightButtonUp=”LayoutRoot_MouseRightButtonUp”
In the codebehind:
using System.Windows.Controls;
…
private void LayoutRoot_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
}
private void LayoutRoot_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
var contextMenu = […]
LINQ to Entities: Deferred Execution and Lazy Loading
How do deferred execution and lazy loading work in LINQ to Entities (Entity Framework)? Let’s find out!
First, some sample data. We don’t want to make it too simple, so let’s have three entities:
Employee, who belongs to a Department
Department, which is under a Functional Group
Functional Group
The data:
Functional Groups
Id
Description
1
Functional Group 01
2
Functional Group 02
Departments
Id
Description
FunctionalGroupId
1
Department 01
1
2
Department 02
2
3
Department 03
2
Employees
Id
First Name
Last […]
Calling a WCF service from PHP
The WCF service needs to use basicHttpBinding.
The PHP code:
define(’NEWLINE’, “<br />\n”);
// SOAP client
$wsdl = ‘http://example.com/SampleWcfService.SampleService.Service?wsdl’;
$soapClient = new SoapClient($wsdl, array(’cache_wsdl’ => 0));
// SOAP call
$sampleData->SampleProperty = “abc”;
$parameters->sampleId = 123;
$parameters->sampleData = $sampleData;
try
{
$result = $soapClient->GetData($parameters);
}
catch (SoapFault $fault)
{
echo “Fault code: {$fault->faultcode}” . NEWLINE;
echo “Fault string: {$fault->faultstring}” . NEWLINE;
if ($soapClient != null)
{
$soapClient = null;
}
exit();
}
$soapClient = null;
//echo “<pre>\n”;
//print_r($result);
//echo “</pre>\n”;
echo “Return value: {$result->GetDataResult}” […]