声明并将集合用作属性 [英] Declaring and using a collection as a Property

查看:83
本文介绍了声明并将集合用作属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的 - 我已经阅读并且我已经玩过了,我一直空白,主题几乎到达那里但是没有



我的两个我的VB2010学习项目中的课程是:项目和目标



两者都存储在相关数据表中,其中每个目标都有一个Project_ID(一对一)许多关系)



我想将Objectives集合作为Projects类的属性。我想我会使用myProject.PopulateObjectives方法填充

OK - I've read and I've played around and I keep coming up blank with topics that almost get there but don't

Two of my classes in my VB2010 learning project are: "Project" and "Objective"

Both are stored in related data tables where each Objective has a Project_ID (a one-to-many relationship)

I want to incorporate an "Objectives" collection as a Property of the Projects class. I'm thinking I would populate that with a myProject.PopulateObjectives method calling

Select* from Objectives WHERE Project_ID=[@Project_ID]



和这将允许我随后对该项目(和其他项目)进行大量计算和迭代



如何为此声明属性和方法?



感谢所有帮助


and that would allow me then to do a number of calculations and iterations with that project (and other projects)

How do I declare the Property and Methods for this?

All help gratefully received

推荐答案

有太多事情要解释......只有一个建议:使用数据访问层从数据库返回数据;)

看看这里:

教程1:创建数据访问层 [ ^ ]

数据访问层(第一部分) [ ^ ]

VB.Net中的通用数据访问层 [ ^ ]
There is too many things to explain... Only one suggestion: use Data Access Layer to return data from database ;)
Have a look here:
Tutorial 1: Creating a Data Access Layer[^]
Data Access Layer (Part I)[^]
A Generic Data Access Layer in VB.Net[^]


我在这里缺少的是我需要a)声明一个名为Objectives as的属性目标b)的集合/列表设置调用以填充目标和c)使用仅限于该项目ID的查询设置子拓扑目标



数据Maciej提出的图层教程非常有用



有时候人们不知道他们不知道什么
What I was missing here was that I needed to a) declare a property called Objectives as a collection/list of Objective b) set up a call to populate the objectives and c) set up a sub topopulate objectives using a query restricted to that projectID

The data layer tutorial proposed by Maciej was very useful

Sometimes people don't know what they don't know


这篇关于声明并将集合用作属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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