0

I've used the Database first approach to generate classes in my MVC application. We have a lot of tables, and some of them have sparse columns (which were all stored as strings, while the table from the database will have a column called "sparse columns" as an "xml" datatype). The issue with this is those sparse columns were also added as part of the partial classes, which I'm worried could lead to performance issues and a lot of null values if I'm trying perform any type of CRUD operation, whether it be reading, updating, etc...

My question is, is there anyway around this? Is there some way to specify what sparse columns I want to populate and/or use per CRUD operation? Is there some way Entity Framework can help with this?

tereško
  • 58,060
  • 25
  • 98
  • 150
  • I can't really picture what your data model and class model look like and how they map onto eachother. Maybe you can add an example. But it looks like _Projection_ is the keyword here, or `Select(x => new { x. ... }`. Only the properties in the `Select` will be queried. Inserts will have to go the whole nine yards though. – Gert Arnold Jun 04 '13 at 20:40
  • Thanks for you response; I appreciate it. So, an example would be like a Student table. The table may have columns like First Name, Last Name, Social Security #, etc. So, I used Entity Framework, which created a public partial class called "Student", and the class properties are First Name, Last Name, etc... – user2317150 Jun 04 '13 at 20:54
  • Sure, but I don't understand the part _sparse columns which were all stored as strings_ (plural) and _a (singular) column called "sparse columns" as an "xml" datatype_. Maybe you can add some code (parts of the class + table definition) to your post. – Gert Arnold Jun 04 '13 at 21:01
  • I see. Sorry for the confusion, as I'm trying to explain it without revealing any actual code (getting help for work-related material). What I meant was that the Student table would have a column called "sparse_columns", and the data type for that "sparse columns" was an xml data type. Then, after Entity Framework would create partial class "Student", it would create every sparse column as something like "public string Distance_to_class", as one sparse column (sorry, can't think of a good sparse column example). Does that help clarify it a bit? – user2317150 Jun 04 '13 at 21:12
  • Hmm not really, sorry. Maybe it's an EF feature I don't know of. But you should be able to snap together a little example, shouldn't you. It would also draw a lot more attention of potential answerers. – Gert Arnold Jun 04 '13 at 21:31

0 Answers0