473,782 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2549
Select the username in the SQL query for the gridview

"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:O0******** ********@TK2MSF TNGP05.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 (uniqueidentifi er), foreign key to aspnet_Users

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

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.NO SPAMwrote in message
news:us******** *****@TK2MSFTNG P02.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 (uniqueidentifi er), foreign key to aspnet_Users

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

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.NO SPAMwrote in message
news:us******** *****@TK2MSFTNG P02.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 (uniqueidentifi er), foreign key to aspnet_Users

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

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
3915
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 versions: mysqld-max-nt --console --transaction-isolation=SERIALIZABLE In 4.0.15-win I can extract the following error after I run the table creation script: ERROR 1005: Can't create table '.\ibdata\#sql-a14_3.frm'
6
2830
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 example. Here's my XML file: <?xml version="1.0"?> <!DOCTYPE para PUBLIC "-//Norman Walsh//DTD Website Full V2.4.0//EN" "http://docbook.sourceforge.net/release/website/2.4.0/website-full.dtd"
2
3158
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 sect1 sect2
11
2394
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 know of a work around? It is a little frustrating that the normally powerful external entities are limited in this fashion. Example (myextent.txt contains just one word without a CR):
1
6595
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 DOCTYPE) while the second one is defined in the external subset (in a separate DTD file) ? Or an
4
7048
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
3187
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 the Data Access Layer method -or- 2) Pass some kind of a unique id to the Data Access Layer method
6
2078
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 Internal General and Character references are included when referenced in content. And "included" means: <quote>
1
2366
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 know I *could* store the data dict values in SQL: for various reasons that's not the path I want to take. I have some lookups, which are based on code-based Objects. They are encapsulated in Objects because the values can change during...
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.