user1641172
user1641172

Reputation:

Generating Typescript Definition from partial classes using Web Essentials

I'm trying to get my typescript definition files generated for my database first entity framework classes using web essentials 2015 with VS 2015.

I followed the example here to generate my .net classes the new way, and i have POCOs for all the tables. e.g.

//module User.cs
public partial class User
{
    public int Id { get; set; }
    public string User { get; set; }
    public DateTime DateOfBirth { get; set; }
}

Usually, i will extend these will some partial classes so i can add some functionality outside of the database, i wouldn't modify my generated code in case i need to regenerate it later.

//module SiteModels.cs
public partial class User
{
    public double DaysOld { get { return (DateTime.Now - DateOfBirth).TotalDays ;  } }
}

But web essentials only looks at the code in the file that i am generating a typescript intellisense file for, so in my typescript definition i only get:

//generated module SiteModels.cs.d.ts
interface User {
        daysOld: number;
    }

So the crux of the problem is: when i have 2 partial class in 2 different files, and i am using web essentials to convert one to a typescript definition file, it's not including all of the properties from both partial classes.

Suggestions for alternate routes are acceptable, but they need to work with ASP NET Core.

Upvotes: 1

Views: 341

Answers (0)

Related Questions