0

I have an entity class say MyEntity.cs that has around 108 properties. In my ASP .net application UI, I am displaying a string value from the database(say for instance) which contains some fieldnames or datapoints delimited in the format <%fieldname%>. The fieldname is nothing but a column name in the table MyTable. I also read MyTable(which has around 108 columns) record(just one single record) and populate the entity MyEntity.

What I need to do is to merge MyEntity property.cs values with the string that contains the <%fieldname%>. I thought of using reflection but the property names in MyEntity.cs might not exactly match the column names in MyTable. So I am not sure how I should proceed.

If there is a way that I can specify a name other than the propertyname for MyEntity properties, so that I can use the MyTable column names in the entity for each property and access them through reflection in my code and replace the string's <%fieldname%> with the MyEntity.cs property values. Any help would be appreciated?

SARAVAN
  • 14,571
  • 16
  • 49
  • 70

1 Answers1

0

entity framework auto generates classes for the tables and stored procs you model. I don't see why you couldn't update those files and change the property names. I probably wouldn't recommend doing this and you'll probably have to re modify them anytime you update your model from the database.

IMO sounds like you have a pretty bad data model... 108 columns in one table? what a nightmare sounds like its not normalized and can't imagine maintenance on that thing.

cobolstinks
  • 6,801
  • 16
  • 68
  • 97
  • I am not using entity framework here. I am using a custom framework developed in the enterprise. It has got some ugly ways of writing the code. I am suggesting to use entity framework. But they don't want to implement that right away. That's the problem. – SARAVAN Oct 03 '12 at 01:35