Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5945977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:45:26+00:00 2026-05-22T16:45:26+00:00

I had so far just a little experience with T4, that’s why I am

  • 0

I had so far just a little experience with T4, that’s why I am asking.

I have such problem — instead of having template which transforms itself into C# code (I would use T4 then) I have external file (template) which I would like to convert to C# code. Here (just an example!) I am building pretty limited (very limited) ORM. So my template looks like this:

Entry
*ID int
*Lang string
Text string

and this should be transformed to full class, which starts like this:

public class Entry
{
  public int ID { get; set; }
  public string Lang { get; set; }
  public string Text { get; set; }

  public object[] PrimaryKeys { get { return new object[] { ID, Lang }; } }

  public void ReadRecord(...
}

Question — what is my next best step: should I my own converted or should I use T4 (or other similar tool).

The one advantage of my own tool I can think of is that IF I have/spend enough time, I could omit template file and create C# relying directly on database structure (in this case) instead of template file.

While answering please make this clear if you recommend your solution in both cases (input: text template vs. binary file, like db).

Remark: please, please, don’t start with “why don’t you use NHibernate/LS2/EF…”. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:45:27+00:00Added an answer on May 22, 2026 at 4:45 pm

    I think T4 will work just fine for your needs. Check out the section “Design-time T4 text templates” in this MSDN link. It describes reading an XML configuration file to drive the code generation. You basically put the code that reads the input file into the first part of the .tt file, and then later reference what you read in as you lay out the classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been updating an Android app today which so far had a single TableLayout
I'm using Symfony 1.4 and Doctrine. So far I had no problem running tasks
So far I have been creating Web Portal but recently I had a request
I have had no luck with this task so far so grateful for any
I've had a login I have used so far to login while I was
In the pages so far, I have had used one connection class and one
I have tried several things so far, but I haven't had much luck yet.
We have an ASP.NET application that users use to generate certain reports. So far
I've had a problem with this little snippet: <script> function download() { alert('Hi'); }
Problem I have a long running import job which I start with an ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.