Tag Archives: ASP.NET

SqlBulkCopy Matching Columns

If you’re trying to do a SqlBulkCopy using a DataTable and getting lots of column type (integer, string) mismatches, it’s probably because you haven’t mapped not only the column types, but also the column names.

SqlBulkCopy assumes that your DataTable is going to have its columns in the same order as the database table, which will cause mismatches when it tries to send your (string) Name field into your (int) Age column.

Just having your DataTable column names match the table isn’t enough, either. There must be a manual mapping.

But if your DataTable column names are the same as the table column names, a simple method can take care of that mapping for any DataTable you send it.

Continue reading SqlBulkCopy Matching Columns

Brain Twist: .NET MVC 3, Entity Framework 4.1, and TDD

Talk about taking a large bite.

In the interests of pushing my .NET knowledge, I began migrating the Geist character sheet project that I’d started in Django to .NET MVC 3. I hadn’t done MVC in .NET since MVC 1 was beta’d, but hey, MVC is MVC is MVC. Right?

So in the interests of making things more interesting and more testable, I decided to dive into the Entity Framework 4. My beginning read of POJOs in Action, along with my previous experience with .netTears–I mean, .netTiers–had me generally familiar with the concepts of entities, contexts, and repositories.

Kicker is, POJOs is just a book (and one I’ve barely dived into), and .netTears uses code generation, meaning I could get away with treating it as just a very hefty ORM in the applications it was in. Generate and go.

Getting my fingers in it was a whole ‘nother experience.

Continue reading Brain Twist: .NET MVC 3, Entity Framework 4.1, and TDD

Quasi-daily linkage

Quasi-daily linkage

Quasi-daily linkage

  • My Java Experience – This is a great post on a .NETer taking a course in Java EE. I haven't done Java EE development before, but this makes me want to try it out of masochism. "All in all, I find myself unimpressed by the amount of work that was shuffled to the tools, it doesn’t seem right. And it seems like a justification of a bad practice. When I consider my own design principles (Zero Friction!) in light of this, I am much happier that I am mainly working in the .NET world. But I think that having this understanding is going to be very helpful moving forward."
  • Coding Horror: The Field of Dreams Strategy – Reader metrics for sites and blogs — while fascinating, fun, and deliciously distracting — don't mean much if you're spending time observing them instead of writing. I like Atwood and O'Brien's approach.