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 8154
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.goog legroups.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.c omwrote in message
news:BD******** *************** ***********@mic rosoft.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.goog legroups.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.c omwrote:
Did it work? Any feedback?
"Ralf Rottmann" <BeSh...@live.c omwrote in message
news:BD******** *************** ***********@mic rosoft.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.goog legroups.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 Recordset with a test or slight change
to field names. Is there a way to Replicate this Method in LINQ, I've tried
setting the Variable as an Object "Dim tDayID AS Object = "tem.Day" & 1" but
it did not work?
IN ACCESS:
Dim DaI As String
DaI =...
|
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 file
suppose file1 like ...
|
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 specified
element's value.
XmlReaderSettings settings = new
XmlReaderSettings();
|
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 find which items in A do not exist in B then:
| |
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 name="item1">value1</
item><item name="item2">value2</item></data></datas>
......
|
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 = q.Where(t =t.Field1==1);
|
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 not reinsert it with a
different revision number.
Compounding the issue, we’ve also got an associated table storing properties
for our entities which is not revisioned, but we still want changes to the
children of our entity (additions, changes...
|
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 into C# LINQ. Notice
that one of the returned fields "XrefID" is coming from the second table.
This information is very important but its complicating the query expression
in C# The DataContext has the two classes for the two tables...
|
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...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |