Skip to content

Instantly share code, notes, and snippets.

@edrohler
Last active August 29, 2015 14:25
Show Gist options
  • Save edrohler/e11489647b3685e5be8b to your computer and use it in GitHub Desktop.
Save edrohler/e11489647b3685e5be8b to your computer and use it in GitHub Desktop.
Entity Framework Migrations Computed Column for DbGeography Location, Tme and Cost
Sql("ALTER TABLE dbo.Profile ADD DisplayName AS FirstName + ' ' + LastName");
Sql("ALTER TABLE dbo.Profile ADD LastNameFirst AS LastName + ', ' + FirstName");
Sql("ALTER TABLE dbo.Profile ADD PublicName AS FirstName + ' ' + SUBSTRING(LastName, 1, 1) + '.'");
Sql("ALTER TABLE dbo.Availability ADD TotalHours AS DATEDIFF(SECOND,BeginTime,Endtime)/3600");
Sql("ALTER TABLE dbo.Rate ADD EstWeeklyRateLow AS HourlyRateLow*DesiredWeeklyHours");
Sql("ALTER TABLE dbo.Rate ADD EstWeeklyRateHigh AS HourlyRateHigh*DesiredWeeklyHours");
Sql("ALTER TABLE dbo.LocationData ADD Location AS geography::Point(Latitude,Longitude, 4326)");
Sql("ALTER TABLE dbo.RefZipCode ADD Location AS geography::Point(Latitude,Longitude, 4326)");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment