473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

entity and foreign key

hi

asp.net 2.0

I have a table, (lets call the table "Car") which links to the aspnet_Users
table. (UserId)

I'm creating an entity class of the car table, containing all the fields in
the car table, except that I'm unsure what to do with the field linking to
aspnet_users. I mean I can just use the UserId column, but in my website I'm
not displaying UserId, but UserName....

I would prefer to add UserId to the entity and then use some other technique
so that the GridView replaces the UserId with the UserName.. as username is
more readable for the humanbeing...

any suggestions?
Nov 16 '08 #1
4 2537
Select the username in the SQL query for the gridview

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:O0****************@TK2MSFTNGP05.phx.gbl...
hi

asp.net 2.0

I have a table, (lets call the table "Car") which links to the
aspnet_Users table. (UserId)

I'm creating an entity class of the car table, containing all the fields
in the car table, except that I'm unsure what to do with the field linking
to aspnet_users. I mean I can just use the UserId column, but in my
website I'm not displaying UserId, but UserName....

I would prefer to add UserId to the entity and then use some other
technique so that the GridView replaces the UserId with the UserName.. as
username is more readable for the humanbeing...

any suggestions?

Nov 17 '08 #2
I know, but I have this GridView based on a custom collection. Lets say a
collection of a Car class (showing information related to cars).

The table which the entity class get it's values from have these fields:
car_id (primary key)
car_make
car_color
car_user (uniqueidentifier), foreign key to aspnet_Users

The car entity has these properties:
car_id
car_make
car_color
car_user (uniqueidentifier)

The enity class holds the same fields as the table

I would prefer if I could make the entity class only have properties which
only is based on the field in which the entity class is based on. This means
that UserName is not put into this entity class..

I know PowerBuilder had a feature for this 6 years ago. There I in a
DataWindow (DataWindow is a data presentation control in PowerBuilder) could
add a id column to the DataWindow. But during runtime get the id column
replaced with another value... Not sure how this could be done in asp.net
2.0 or if it's best practice

Any ideas?
Nov 17 '08 #3
An entity class can contain any element you want. You can't have your
preference and get something for free (?)

Here is an entity class that contains other elements:

http://msdn.microsoft.com/en-us/library/cc514504.aspx

Bottom line you are going to have to hit the database to get the username

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:us*************@TK2MSFTNGP02.phx.gbl...
>I know, but I have this GridView based on a custom collection. Lets say a
collection of a Car class (showing information related to cars).

The table which the entity class get it's values from have these fields:
car_id (primary key)
car_make
car_color
car_user (uniqueidentifier), foreign key to aspnet_Users

The car entity has these properties:
car_id
car_make
car_color
car_user (uniqueidentifier)

The enity class holds the same fields as the table

I would prefer if I could make the entity class only have properties which
only is based on the field in which the entity class is based on. This
means that UserName is not put into this entity class..

I know PowerBuilder had a feature for this 6 years ago. There I in a
DataWindow (DataWindow is a data presentation control in PowerBuilder)
could add a id column to the DataWindow. But during runtime get the id
column replaced with another value... Not sure how this could be done in
asp.net 2.0 or if it's best practice

Any ideas?

Nov 17 '08 #4
Instead of a table, base your entity class on a view

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:us*************@TK2MSFTNGP02.phx.gbl...
>I know, but I have this GridView based on a custom collection. Lets say a
collection of a Car class (showing information related to cars).

The table which the entity class get it's values from have these fields:
car_id (primary key)
car_make
car_color
car_user (uniqueidentifier), foreign key to aspnet_Users

The car entity has these properties:
car_id
car_make
car_color
car_user (uniqueidentifier)

The enity class holds the same fields as the table

I would prefer if I could make the entity class only have properties which
only is based on the field in which the entity class is based on. This
means that UserName is not put into this entity class..

I know PowerBuilder had a feature for this 6 years ago. There I in a
DataWindow (DataWindow is a data presentation control in PowerBuilder)
could add a id column to the DataWindow. But during runtime get the id
column replaced with another value... Not sure how this could be done in
asp.net 2.0 or if it's best practice

Any ideas?

Nov 18 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: geoff | last post by:
The table creation script(at the end of this post) works fine on 4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I am starting the server with the same command for both...
6
by: Vincent Lefevre | last post by:
I would like to know if the base URI considered to resolve an unparsed entity defined by a relative URI should be the URI before or after its rewriting due to a possible catalog. Let's take an...
2
by: Ed Dennison | last post by:
I'm starting to look at DocBook-XML (not SGML) for producing a large documentation set. The hierarchy of DocBook elements for organizing the content is (more or less); set book part chapter...
11
by: Douglas Reith | last post by:
Hi There, Can someone please tell me why the XML spec states that an attribute value with an external entity is forbidden? Or point me to the appropriate document? Or better still, perhaps you...
1
by: Razvan | last post by:
Hi What is the difference between an internal and an external entity ? The first one is defined in the internal subset (not in a separate DTD file, but in the XML file itself - in...
4
by: terry | last post by:
could someone tell me how to add or remove entity to a xml file when i dim xmlentity as new xmlentity it's say it's sube new is private thks
11
by: Arsen Vladimirskiy | last post by:
Hello, If I have a few simple classes to represent Entities such as Customers and Orders. What is the proper way to pass information to the Data Access Layer? 1) Pass the actual ENTITY to...
6
by: Tuomas Rannikko | last post by:
Hello, I'm currently writing a XML processor for the fun of it. There is something I don't understand in the spec though. I'm obviously missing something important. The spec states that both...
1
by: markla | last post by:
Hi, I have an Entity data model built in Entity Framework, which sources data primarily from an MS SQL 2008 database, and sources some static (data dictionary) values from code-based objects. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.