Skip to content

Instantly share code, notes, and snippets.

View jholt456's full-sized avatar

Joshua Holt jholt456

  • WellDatabase
  • Houston, TX
View GitHub Profile
@jholt456
jholt456 / Initialize.cs
Created September 8, 2011 21:18
Custom OpenAccess TypeConverter Initialize method
public override Data.AdoTypeConverter Initialize(Data.IDataColumn user, Type clr, Data.IAdoTypeConverterRegistry registry, bool secondaryTable)
{
//first we need to ensure that the clr type can be handled by this converter
if (clr == typeof(int) && user.ResolvedSqlType == "varchar")
{
//then we need to set a flag to determine if the type is nullable
nullable = typeof(int?) == clr;
//finally return base.Initialize, which ultimatly returns "this"
return base.Initialize(user, clr, registry, secondaryTable);
@jholt456
jholt456 / CreateLiteralSql.cs
Created September 8, 2011 21:14
Custom OpenAccess TypeConverter CreateLiteralSql method
public override bool CreateLiteralSql(ref Data.DataHolder holder)
{
//If there is no value, then we want to query against null.
if (holder.NoValue)
{
holder.StringValue = "NULL";
//returning false indicates that no quotes are required. We want NULL instead of 'NULL'
return false;
}
<!--Add the rad map-->
<telerik:RadMap x:Name="RadMap1"
Center="38.0, -98.371616833534"
ZoomLevel="4">
<!--Set the map provider-->
<telerik:RadMap.Providers>
<telerik:OpenStreetMapProvider />
</telerik:RadMap.Providers>
<!--Create an information layer to display our shapes-->
<telerik:InformationLayer x:Name="InformationLayer">
<Grid.Resources>
<!--Add the extended data converter so we can read the extended data in the tooltip-->
<telerik:ExtendedDataConverter x:Key="ExtendedDataConverter" />
<!--Create a template for the county tooltips, using the ExtendedDataConverter-->
<DataTemplate x:Key="CountyToolTipDataTemplate">
<StackPanel Margin="10,5">
<TextBlock FontWeight="Bold" Text="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='Name'}" />
<TextBlock Text="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='StateName'}" />
</StackPanel>
<Grid.Resources>
<!--Add the extended data converter so we can read the extended data in the tooltip-->
<telerik:ExtendedDataConverter x:Key="ExtendedDataConverter" />
<!--Create a template for the county tooltips, using the ExtendedDataConverter-->
<DataTemplate x:Key="CountyToolTipDataTemplate">
<StackPanel Margin="10,5">
<TextBlock FontWeight="Bold" Text="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='Name'}" />
<TextBlock Text="{Binding Converter={StaticResource ExtendedDataConverter}, ConverterParameter='StateName'}" />
</StackPanel>
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.DataContext = new ViewModels.MapViewModel();
}
}
@jholt456
jholt456 / gist:1112733
Created July 28, 2011 22:31
Code to call a wcf data service and get back entities
public class MapViewModel : INotifyPropertyChanged
{
private SilverlightSqlSpatial.Service.DataManager dataContext;
private DataServiceQuery<County> query;
private ObservableCollection<County> spatialData;
public MapViewModel()
{
dataContext = new SilverlightSqlSpatial.Service.DataManager(new Uri("http://localhost:YOURPORT/SampleServiceName.svc/"));
public partial class County
{
public string GeographyWKT
{
get
{
return this.Geography.STAsText().ToSqlString().Value;
}
}
}