I’m not insane am I?

At my job we use .NET and Typescript for the front end. We have a web service that returns objects, but only their ids. Example:

 public class Test { public int id { get; set;} public TestType typeOfTest {get; set;} } public class TestType { public int TestTypeId { get; set;} public string Name {get; set;} } 

if we call GetTest(), it returns something like this:

public class TestResponse { public int TestId {get; set;} public int TestTypeId {get; set;} } 

normally with Entity Framework, you would write a query like

 var testResponse = _dbContext.Tests.Include(t => t.TestType).ToList(); 

This would return a Test object with a virtual navigation property of TestType. You could then call


and get the value.

The senior devs here instead like to only send the TestResponse with ids to the front end, then in a separate call, send all the TestTypes to the front end into a typescript array. Then in a typescript file, we resolve TestType.Name by by searching for the correct TestTypeId in the array.

This is flat out wrong isn't it? I'm not going insane am I? Shouldn't this all be done on the web service side, not in a .ts file?!

by bonesingyre via /r/csharp

Leave a Reply