473,774 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Concatenating IEnumerable?

Thanks guys for all the guidance on this so far.

In the below, for _IEnumerable2, I'm just trying to hard-code one record
with "(Please Select)" for a value. I can do that easily in SQL but don't
know how here.

Any contunued help very much appreciated... Ron
Dim _IEnumerable1 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable2 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable3 As IEnumerable(Of IEnumerable) = _
_IEnumerable1.C oncat(_IEnumera ble2)

Feb 5 '08 #1
4 4572
Ronald,

You want to do something like this:

Dim _IEnumerable2 as IEnumerable(Of IEnumerable) = _
From item in new string[]{"(Please Select)"}
Select New (LookupId = 0, LookupCode = 0, LookupValue = item)

I'm guessing what the syntax is for VB (and that IEnumerable of
IEnumerable looks odd), but the point is you can simply create an enumerable
of one element (an array of one element is enumerable) and then select the
appropriate data structure to concatenate with your previous data structure.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Ronald S. Cook" <rc***@westinis .comwrote in message
news:57******** *************** ***********@mic rosoft.com...
Thanks guys for all the guidance on this so far.

In the below, for _IEnumerable2, I'm just trying to hard-code one record
with "(Please Select)" for a value. I can do that easily in SQL but don't
know how here.

Any contunued help very much appreciated... Ron
Dim _IEnumerable1 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable2 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable3 As IEnumerable(Of IEnumerable) = _
_IEnumerable1.C oncat(_IEnumera ble2)

Feb 5 '08 #2
Thanks Nicholas.. will try. Sorry about the VB. I code in both and get
crossed up sometimes.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:Ow******** ******@TK2MSFTN GP05.phx.gbl...
Ronald,

You want to do something like this:

Dim _IEnumerable2 as IEnumerable(Of IEnumerable) = _
From item in new string[]{"(Please Select)"}
Select New (LookupId = 0, LookupCode = 0, LookupValue = item)

I'm guessing what the syntax is for VB (and that IEnumerable of
IEnumerable looks odd), but the point is you can simply create an
enumerable of one element (an array of one element is enumerable) and then
select the appropriate data structure to concatenate with your previous
data structure.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Ronald S. Cook" <rc***@westinis .comwrote in message
news:57******** *************** ***********@mic rosoft.com...
>Thanks guys for all the guidance on this so far.

In the below, for _IEnumerable2, I'm just trying to hard-code one record
with "(Please Select)" for a value. I can do that easily in SQL but
don't know how here.

Any contunued help very much appreciated... Ron
Dim _IEnumerable1 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable2 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable3 As IEnumerable(Of IEnumerable) = _
_IEnumerable1.C oncat(_IEnumera ble2)

Feb 5 '08 #3
Nicholas.. I'm having a few twinge pains with that syntax. Could you give
it to me in C# and I'll convert? I REALLY appreciate it and promise not to
bug anymore.

Thanks!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:Ow******** ******@TK2MSFTN GP05.phx.gbl...
Ronald,

You want to do something like this:

Dim _IEnumerable2 as IEnumerable(Of IEnumerable) = _
From item in new string[]{"(Please Select)"}
Select New (LookupId = 0, LookupCode = 0, LookupValue = item)

I'm guessing what the syntax is for VB (and that IEnumerable of
IEnumerable looks odd), but the point is you can simply create an
enumerable of one element (an array of one element is enumerable) and then
select the appropriate data structure to concatenate with your previous
data structure.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Ronald S. Cook" <rc***@westinis .comwrote in message
news:57******** *************** ***********@mic rosoft.com...
>Thanks guys for all the guidance on this so far.

In the below, for _IEnumerable2, I'm just trying to hard-code one record
with "(Please Select)" for a value. I can do that easily in SQL but
don't know how here.

Any contunued help very much appreciated... Ron
Dim _IEnumerable1 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable2 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable3 As IEnumerable(Of IEnumerable) = _
_IEnumerable1.C oncat(_IEnumera ble2)

Feb 5 '08 #4
Ronald,

Actually, the syntax was a bad mix of C#, now that I look at it.

In C#, I would do this:

var _IEnumerable2 =
from item in new string[] { "(Please Select)" }
select new { LookupId = 0, LookupCode = 0, LookupValue = item };

Of course, if 0 isn't applicable for the LookupId and LookupCode
properties on your anonymous type, then you need to replace them with
something that is.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ronald S. Cook" <rc***@westinis .comwrote in message
news:9E******** *************** ***********@mic rosoft.com...
Nicholas.. I'm having a few twinge pains with that syntax. Could you give
it to me in C# and I'll convert? I REALLY appreciate it and promise not
to bug anymore.

Thanks!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote
in message news:Ow******** ******@TK2MSFTN GP05.phx.gbl...
>Ronald,

You want to do something like this:

Dim _IEnumerable2 as IEnumerable(Of IEnumerable) = _
From item in new string[]{"(Please Select)"}
Select New (LookupId = 0, LookupCode = 0, LookupValue = item)

I'm guessing what the syntax is for VB (and that IEnumerable of
IEnumerable looks odd), but the point is you can simply create an
enumerable of one element (an array of one element is enumerable) and
then select the appropriate data structure to concatenate with your
previous data structure.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Ronald S. Cook" <rc***@westinis .comwrote in message
news:57******* *************** ************@mi crosoft.com...
>>Thanks guys for all the guidance on this so far.

In the below, for _IEnumerable2, I'm just trying to hard-code one record
with "(Please Select)" for a value. I can do that easily in SQL but
don't know how here.

Any contunued help very much appreciated... Ron
Dim _IEnumerable1 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable2 As IEnumerable(Of IEnumerable) = _
From lk In dc.Lookups _
Where lk.LookupGroup = LookupGroup _
Select lk.LookupId, _
lk.LookupCode, _
lk.LookupValue

Dim _IEnumerable3 As IEnumerable(Of IEnumerable) = _
_IEnumerable1.C oncat(_IEnumera ble2)


Feb 5 '08 #5

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

Similar topics

10
2753
by: jcc | last post by:
Hi guys, I'm a newbie to C#. My Visual Studio 2005 failed to compile the following code with error as 'HelloWorld.A' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'HelloWorld.A.GetEnumerator()' is either static, not public, or has the wrong return type. class A : IEnumerable<string>
3
5110
by: KH | last post by:
I can't seem to figure this one out... I've searched MSDN and Goog, and made my best guesses to no avail,, so help would be much appreciated! public ref class T sealed : public System::Collections::IEnumerable , public System::Collections::Generic::IEnumerable<int> { // How to implement GetEnumerator() for both interfaces? // Compiler complains that functions differ only in return type // which I understand, but can't get the right...
5
4205
by: Tin Gherdanarra | last post by:
Dear mpdls, here is a simple example of an IEnumerable that generates integers: It works, but I have only a vague idea of what's going on. I understand that /yield/ wraps the humble integer that comes from counter++
1
2984
by: =?Utf-8?B?RnJhbmNvaXNWaWxqb2Vu?= | last post by:
Hi there, Does anybody know how to return the results of an IEnumerable<typeas an array of the same type i.e type in a web service call without first having to collect all elements in the IEnumerable<typeand storing it in memory first? This question is really about optimizing large collections of data returned by web services. If it is possible to loop through the IEnumerable<type> with a "foreach" and somehow start formatting the...
2
4240
by: =?Utf-8?B?a2VubmV0aEBub3NwYW0ubm9zcGFt?= | last post by:
When creating multiple iterators, the original is defined as returning IEnumerator, ie public IEnumerator GetEnumerator() { yield x; ...} whereas the additional ones are defined as returning IEnumerable, ie public IEnumerable AnotherSortOrder() { yield x;....} Any insights out there as to why the additional iteration methods did not just return IEnumerator? (its just a little confusing, hoping for some better insight)
2
4586
by: Morgan Cheng | last post by:
In .Net 2.0, Generics are introduced. I found that IEnumerable<T> inherites from IEnumerable. This makes implementation of IEnumerable<Thas to have two GetEnumerator methods defined( one for IEnumerable<Tand the other for IEnumerable). I doubt why .Net class hierarchy is designed in such a way. IMHO, they should not have inheritance releationship, just like IList<Tand IList. I googled the web and found two related articles....
12
2414
by: gnewsgroup | last post by:
I've read the msdn doc about IEnumerable. It seems to me that IEnumerable objects are essentially wrapped-up arrays. It simply gives us the foreach convenience. Is this correct?
2
2499
by: Tony Johansson | last post by:
Hello! Below I have a working program. I have one generic class called Farm<T> with this header definition public class Farm<T: IEnumerable<Twhere T : Animal Now to my question I changed the inheritance of the IEnumerable from the generic IEnumerable<T> to the generel IEnumerable and the program function just the same so no
1
2018
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
Something I found surprising this week involves the IEnumerable<Tinterface. I have a class that I wrote a couple of years ago which implements the IEnumerable interface. This week I realized it should implement IEnumerable<T>. But when I changed the return type of the GetEnumerator method the compiler said the class no longer implemented IEnumerable. IEnumerable<Thas IEnumerable as a base interface, so I had assumed that implementing...
0
9621
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
9454
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
10106
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
10040
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,...
1
7463
isladogs
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...
0
6717
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
4012
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
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
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.