帮助我了解需要发生的事情 [英] Help me understand what needs to happen

查看:64
本文介绍了帮助我了解需要发生的事情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要做的,我正在创建一个WinForms应用程序,基本上,
(1)我想加入两个表并根据字段值查询并返回一个字段
(2) )我想检查表中是否存在列,如果不存在,请添加列

之前我没有使用过Linq-to-sql,所以我甚至不确定这是否可行。但我试图跟上新技术的步伐,所以我试图了解需要发生什么。如果我不应该使用Linq-To-Sql,请告诉我。

首先,我通过WinForm应用程序上的对话框获取用户数据库连接信息。那么可以/如何为我需要的表动态创建datacontext / entity类?在我学到的所有内容中,我一直在通过ORM创建数据上下文/实体类,现在在一个真实世界的应用程序中我看不出那是可能的,因为一切都应该动态生成。

再次,这可能通过一个简单的t-sql查询解决,但就像我说的,我试图给linq-to-sql一个镜头。我只是寻找一些方向,看看它是否值得麻烦。
谢谢你


你是如此聪明......就像一个毛皮覆盖的微型budha。 -Anchorman

解决方案



>那么可以/如何为我需要的表动态创建datacontext / entity类?

datacontext的构造函数接受一个字符串,允许您实例化该目标数据库。


Here is what im trying to do, I am creating a WinForms application and basically,
(1) i want to join two tables and query based on a field value and return a field
(2) i want to check if a column exists in a table, if it doesnt, add the column

I havent used Linq-to-sql before, so im not even sure if thats the way to go. But im trying to stay abreast of new technology so im trying to understand what needs to happen. If I should not use Linq-To-Sql please let me know as well.

First off, I get the users database connection information via a dialog box on the WinForm app. So can/how do I create the datacontext/entity classes dynamically for the tables that I require? In everything I have learnt, Ive been creating the data context/entity classes via the ORM and now in a real world application I dont see how thats possible because everything should be generated dynamically.

Again, this maybe solved by a simple t-sql query, but like i said, im trying to give linq-to-sql a shot. Im just looking for some direction and to see if its even worth the trouble.
Thanks


You are so wise...like a miniature budha covered in fur. -Anchorman

解决方案



> So can/how do I create the datacontext/entity classes dynamically for the tables that I require?

The constructor for the datacontext takes a string which will allow you to instantiate that target database.


这篇关于帮助我了解需要发生的事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆