Hello,
I have 3 SQL tables:
[Tags] TagId, TagText
[Posts] PostId, TagId, ...
[Files] FileId, TagId, ...
I need to, using LINQ, select all records in Tags, including the
columns TagId and TagText, but adding a new column of type boolean
which is True if the tag is associated to a Post OR to a File, i.e.,
if the TagId exists in Posts or Files.
How can I do this?
Thanks,
Miguel 3 8134
Miguel,
Have you used the new O/RM tool within Visual Studio 2008 to create the db
context?
You should then be able to express:
var query = from t in db.Tags
select new
{
TagId = t.TagId,
TagText = t.TagText,
hasPosts = t.Posts 0,
hasFiles = t.Files 0
};
This is supposed to work because LINQ to SQL exposes the foreign key
relationship as a collection at the object level.
Please lest me/us know how it goes!
Best regards
-Ralf http://www.24100.net
"shapper" <md*****@gmail.comwrote in message
news:11**********************@o3g2000hsb.googlegro ups.com...
Hello,
I have 3 SQL tables:
[Tags] TagId, TagText
[Posts] PostId, TagId, ...
[Files] FileId, TagId, ...
I need to, using LINQ, select all records in Tags, including the
columns TagId and TagText, but adding a new column of type boolean
which is True if the tag is associated to a Post OR to a File, i.e.,
if the TagId exists in Posts or Files.
How can I do this?
Thanks,
Miguel
Did it work? Any feedback?
"Ralf Rottmann" <Be*****@live.comwrote in message
news:BD**********************************@microsof t.com...
Miguel,
Have you used the new O/RM tool within Visual Studio 2008 to create the db
context?
You should then be able to express:
var query = from t in db.Tags
select new
{
TagId = t.TagId,
TagText = t.TagText,
hasPosts = t.Posts 0,
hasFiles = t.Files 0
};
This is supposed to work because LINQ to SQL exposes the foreign key
relationship as a collection at the object level.
Please lest me/us know how it goes!
Best regards
-Ralf
http://www.24100.net
"shapper" <md*****@gmail.comwrote in message
news:11**********************@o3g2000hsb.googlegro ups.com...
>Hello,
I have 3 SQL tables:
[Tags] TagId, TagText [Posts] PostId, TagId, ... [Files] FileId, TagId, ...
I need to, using LINQ, select all records in Tags, including the columns TagId and TagText, but adding a new column of type boolean which is True if the tag is associated to a Post OR to a File, i.e., if the TagId exists in Posts or Files.
How can I do this?
Thanks, Miguel
On Nov 9, 2:50 pm, "Ralf Rottmann \(www.24100.net\)"
<BeSh...@live.comwrote:
Did it work? Any feedback?
"Ralf Rottmann" <BeSh...@live.comwrote in message
news:BD**********************************@microsof t.com...
Miguel,
Have you used the new O/RM tool within Visual Studio 2008 to create the db
context?
You should then be able to express:
var query = from t in db.Tags
select new
{
TagId = t.TagId,
TagText = t.TagText,
hasPosts = t.Posts 0,
hasFiles = t.Files 0
};
This is supposed to work because LINQ to SQL exposes the foreign key
relationship as a collection at the object level.
Please lest me/us know how it goes!
Best regards
-Ralf
http://www.24100.net
"shapper" <mdmo...@gmail.comwrote in message
news:11**********************@o3g2000hsb.googlegro ups.com...
Hello,
I have 3 SQL tables:
[Tags] TagId, TagText
[Posts] PostId, TagId, ...
[Files] FileId, TagId, ...
I need to, using LINQ, select all records in Tags, including the
columns TagId and TagText, but adding a new column of type boolean
which is True if the tag is associated to a Post OR to a File, i.e.,
if the TagId exists in Posts or Files.
How can I do this?
Thanks,
Miguel
Hello,
Sorry, I was out of work. I didn't try it yet.
I was trying to put this in a LINQ Data Source.
This is something I am not sure. Is it possible to use any LINQ query
in a LINQ Data Source?
Thanks,
Miguel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: shapper |
last post by:
Hello,
I have 2 tables:
Aid, Aname ...
Bid, Aid, Bname ...
I need to get the records in B given a Bname and a Aname. I think I
should use Inner Join.
I wrote the following code:
|
by: john |
last post by:
LINQ works a lot like an Access DB Recordset in the way it functions, one of
the things I could do in Access is refer to the Fields thru a Variable as
below allowing me to Iterate over the...
|
by: ranganadh |
last post by:
Dear Group members,
I am new to LINQ, pls help on the deeling with huge amount of data
with the C# stand Alone application.
I have two file, which contains more then 2 lacs lines in every...
|
by: luowan |
last post by:
Hi
I am currently building an application on .NetCF 3.5 in C#. The
application needs to process xml files. I am thinking about using LINQ
to process XML. I wrote a piece of code to modify the...
|
by: shapper |
last post by:
Hello,
I have two Lists:
A = {ID, Name} = { (Null, John), (Null, Mary), (Null, Andrew), (Null,
Peter) }
B = {ID, Name} = { (1, John), (2, Robert), (3, Angela), (4, Andrew) }
I want to...
|
by: timor.super |
last post by:
Hi group,
In my database, I have a table with fields like this :
id | title | xml
------------------------------------
1 | title1 | <datas><data><item...
|
by: =?Utf-8?B?Tmljaw==?= |
last post by:
Hello,
I need some assistance with a LINQ query. I've got a simple query:
var q = from t in db.Table1 select t;
Based on user input I'm adding some where clauses:
if (condition1)
q =...
|
by: =?Utf-8?B?RXJpYyBGYWxza2Vu?= |
last post by:
We’re storing our main entity in an insert only table which stores the
history of past revisions, but we’re facing problems with storing this
history as LINQ will only update the entity, and...
|
by: Dan Tallent |
last post by:
I have a query which I would like to convert to LINQ. I am having
problems finding good examples or references that cover more complex
queries.
Here is the SQL command I would like to rewrite...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |