Here is how you do it:
Step 1: In edmx
<Function Name="DistanceBetween" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<CommandText>
select dbo.DistanceBetween(@lat1,@long1,@lat2,@long2)
</CommandText>
<Parameter Name="Lat1" Type="real" Mode="In" />
<Parameter Name="Long1" Type="real" Mode="In" />
<Parameter Name="Lat2" Type="real" Mode="In" />
<Parameter Name="Long2" Type="real" Mode="In" />
</Function>
step 2: Import the function
- double click the
edmx
- In the Model Browser view, expand
GeoDataModel.Store
(could be named different)
- expand
stored procedures /function
- double click
DistanceBetween
Scalars = Single
- Click OK
Step 3: In C#:
GeoDataEntities db = new GeoDataEntities();
var first = db.DistanceBetween(234, 2342, 424, 243).First().Value;
note that IsComposable="false"
and no ReturnType
and dont forget to add the :
<CommandText>
select dbo.DistanceBetween(@lat1,@long1,@lat2,@long2)
</CommandText>
Hope that help....