Skip to content

Commit

Permalink
Migrate UDF Sql Server test from Northwind database to custom database
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiddleton authored and AndriySvyryd committed Aug 31, 2017
1 parent d3cb5b9 commit f2683c5
Show file tree
Hide file tree
Showing 3 changed files with 577 additions and 413 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,88 +26,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<CustomerOrderHistory>().HasKey(coh => coh.ProductName);
modelBuilder.Entity<MostExpensiveProduct>().HasKey(mep => mep.TenMostExpensiveProducts);

var methodInfo = typeof(NorthwindRelationalContext)
.GetRuntimeMethod(nameof(MyCustomLength), new[] { typeof(string) });

modelBuilder.HasDbFunction(methodInfo)
.HasTranslation(args => new SqlFunctionExpression("len", methodInfo.ReturnType, args));

modelBuilder.HasDbFunction(typeof(NorthwindRelationalContext)
.GetRuntimeMethod(nameof(IsDate), new[] { typeof(string) }))
.HasSchema("");
}

public enum ReportingPeriod
{
Winter = 0,
Spring,
Summer,
Fall
}

public static int MyCustomLength(string s)
{
throw new Exception();
}

public static bool IsDate(string date)
{
throw new Exception();
}

[DbFunction(FunctionName = "EmployeeOrderCount")]
public static int EmployeeOrderCount(int employeeId)
{
throw new NotImplementedException();
}

[DbFunction(FunctionName = "EmployeeOrderCount")]
public static int EmployeeOrderCountWithClient(int employeeId)
{
switch (employeeId)
{
case 3:
return 127;
default:
return 1;
}
}

[DbFunction]
public static bool IsTopEmployee(int employeeId)
{
throw new NotImplementedException();
}

[DbFunction]
public static int GetEmployeeWithMostOrdersAfterDate(DateTime? startDate)
{
throw new NotImplementedException();
}

[DbFunction(Schema = "dbo")]
public static DateTime? GetReportingPeriodStartDate(ReportingPeriod periodId)
{
throw new NotImplementedException();
}

[DbFunction(Schema = "dbo")]
public static string StarValue(int starCount, int value)
{
throw new NotImplementedException();
}

[DbFunction(Schema = "dbo")]
public static int AddValues(int a, int b)
{
throw new NotImplementedException();
}

[DbFunction(Schema = "dbo")]
public static DateTime GetBestYearEver()
{
throw new NotImplementedException();
}
}
}
Binary file modified test/EFCore.SqlServer.FunctionalTests/Northwind.sql
Binary file not shown.
Loading

0 comments on commit f2683c5

Please sign in to comment.