Вопрос

New user so I hope I can tell you what I want ---

I have a information in my database. I need to get that information in a seeder class in C#. I would rather not have to re-type the whole thing one line at a time.

Is there any way for me to do this? I am using Visual Studio 2012 and Microsoft SQL Server Management Studio if that makes any difference!

For example, I have CategoryId, Category as my table headers and the table is populated with autogenerated ID's but I have put in lots of categories.

PLEASE remember I am a new user so break down your answers with lots of examples PLEASE!!!

Thank you!

Это было полезно?

Решение

Your question is rather vague.

If your general problem can be re-stated as "How can I easily turns rows of data in my database into objects in C# with as little code as possible?", then I would recommend learning how to use an ORM layer. I use NHibernate to great effect. It provides a way of mapping tables in a database to classes in C# and does a ton of CRUD (CReate/Update/Delete) work for you. The alternative is to do the grunt work of writing stored procedures, pulling values out of a data set and constructing objects yourself; all of which is very tedious without an ORM layer.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top