.NET Equivalent To This C# Linq Class?
Sep 25, 2009
I'm trying to convert something from C# to VB.NET and I'm having trouble finding an equivlent in VB.NET to C#'s yield keyword. I realize 'yield' is not a convertable keyword to VB.NET, so can someone please show me how I would implement this code in VB.NET. I got all of it converted over except for the implemented GetEnumerator() function. It is simply a class that implements CollectionBase and IEnumerable (to make it LINQ worthy):
[Serializable()]
public partial class Customers : CollectionBase, System.Collections.Generic.IEnumerable<BusinessLayer.Customer>
{
[code]....
View 4 Replies
ADVERTISEMENT
Jul 20, 2011
I have the following query in VB, but I do not know how to translate it to C# synatax
Dim q = From c In db.Customers
Group Join o In db.Orders On c.CustomerID Equals o.CustomerID Into orders = Group
Select New With {c.ContactName, .OrderCount = orders.Count()}
View 2 Replies
Feb 12, 2010
Is there a LINQ To SQL equivalent to the SQL between keyword?[code]...
View 2 Replies
Jun 12, 2012
Find the Linq equvalent on the below sql query:
select sum(weight) from (
select weight from pers p
join list l on l.persindex= p.persindex
group by p.persindex,weight) a
View 3 Replies
Mar 5, 2012
This is the query that I'm trying to reproduce:
[Code]...
View 1 Replies
Sep 18, 2009
Not sure if this is just a bad habit, or a valid way of doing things, but for large complex report queries spanning bunches of tables, I often get my aggregate stats by summing a Case statement.For example:
SELECT Contact.Name,
SUM(CASE WHEN Order.Type = 'Special' THEN 1 ELSE 0 END) AS SpecialOrders,
SUM(CASE WHEN Order.Type = 'Magic' THEN 1 ELSE 0 END) AS MagicOrders,
[code].....
View 2 Replies
Sep 22, 2010
Some long-gone developer left the following LINQ query behind with no documentation and I'm struggling to understand what it does (and therefore if it's doing it right), either by breaking it into pieces or providing the SQL equivalent?
CODE:
I am struggling in particular with the Group Join and Into TargetMatches = Group pieces:
CODE:
View 1 Replies
Mar 19, 2010
Is there a VB.NET equivalent to the C# var keyword? I would like to use it to retrieve the result of a LINQ query.
View 4 Replies
Jun 29, 2010
I'm trying to translate some C# LINQ code into VB.NET and am stuck on how to declare an anonymous type in VB.NET.[code]How do you translate C#'s new { ... } syntax into VB.NET?
View 2 Replies
May 3, 2011
I'd normally do this in C# but since I've got to get this code in this particular assembly which is a vb.net one, I'm stuck.
Here's my linq query:
Dim i As Integer = 0
Dim oldAndCurrentIntersectionOnNames = From currentApplicant In currentApplicants _
Group Join oldApplicant In oldApplicants _
[CODE]...
You'll see the .Index = i+=1
This was my attempt to do what I'd quite happily do in C# (i.e. Index = i++) in VB. Unfortunately the VB compiler doesn't like that. how I'd do this in VB.
View 2 Replies
May 14, 2012
I am migrating vb6 to vb.net. I am using class insted of classmodule is it right? or any thing equalent to classmodule in .net ?
View 1 Replies
Nov 30, 2007
what is the Equivalent of a Static class in VB.Net. Is it Modules?And When i used one of the C# to VB.Net conversion tools then the code "Public Static class Class1 " was converted to "Public NotInheritable Class Class1"
View 1 Replies
Jun 11, 2012
As discribed on this MSDN pageWhat would be the PHP equivalent? Is it even possible to do the three things listed on that page under remarks Streams involve three fundamental operations:You can read from streams. Reading is the transfer of data from astream into a data structure, such as an array of bytes.You can write to streams. Writing is the transfer of data from a datastructure into a stream.Streams can support seeking. Seeking is the querying and modifying ofthe current position within a stream. Seek capability depends on thekind of backing store a stream has. For example, network streams haveno unified concept of a current position, and therefore typically donot support seeking.
View 2 Replies
Jun 9, 2010
If I have a module in a VB.Net class library, will it's visibility be limited to the assembly? What I'm looking for is the VB.Net equivalent of a C# internal static class.
View 1 Replies
Oct 14, 2009
I have a very interesting LINQ question. I have a document, that I am trying to filter results on, but to filter, I am matching on a REGEX result from one element of the XML. I have the following, working LINQ to XML to get the individual data that I'm looking for.
[Code]...
View 3 Replies
Apr 28, 2011
Just a quick question about LINQ, I want to use a value from the returned dataset to lookup a value and return this. The line I am struggling with is .ViewingNotes = NewViewing(pt.ProspectId).GetViewings().Columns(7).ToString(). Is this possible?
With BusinessLayerObjectManager.Context
Return (From p As [Property] In .PropertySet
Join pt As Prospect In .Prospects On pt.Property.propertyID Equals p.propertyID
[code].....
View 1 Replies
Dec 10, 2010
I have the following XML file
<Test>
<Modules>
<Module Name= "Test1">
<QueueName Name="Test1Active1" Active="True"></QueueName>
<QueueName Name="Test1Active2" Active="True"></QueueName>
[Code]...
View 1 Replies
Apr 5, 2011
I'm trying to create a list of all my objects from several lists of objects using Union.
Return Chart.AnnotativeNodes.Union( _
Chart.DecisionNodes.Union( _
Chart.EndNodes.Union( _
Chart.StartNodes.Union(Chart.WorkCenterNodes))))
The above line gets an error because I can't union List(of AnnotativeNode) with List(of DecisionNode). Each list defined like List(of EndNode) or List(of StartNode), but each class inherits from the base type Node.Is there a possible way to union these to get a result of IEnumerable(of Node)?
View 1 Replies
Aug 8, 2010
I call upon the VB ninjas out there. Here's my situation. I need to eventually be able to pass multiple models to a view. Currently I have a linq to sql class that, of course, has a bunch of generated model definitions. I need to make a model that implements multiple models. I somewhat understand how to do this in C#, but this project is testing my VB skillz. Here's some snippets from my linq to sql models. I need to combine these two into one model to pass to the view.
[Code]...
View 1 Replies
May 13, 2011
I have an array of unknown (to the current method) class objects. I do know that each class has a property called "Number". I am trying to write a LINQ query where I am looking for the object with the next Number in sequence. AKA, I'm at Number 8, use a LINQ query to find the object where Number=9.
View 5 Replies
Sep 29, 2011
I have a datatable being returned by my DAL. In my BAL I want to return a class object. So I have a class called BusinessArea that has ID, Description and Active properties. I tried this:
[Code]...
View 2 Replies
Apr 30, 2010
I'm using the following code to sort a List(of Class) using LINQ. It works fine, but I'm wondering if there is a better way to do it. I'm basically taking one list, applying LINQ to it, then using the result to create a second list in the sorted order. Can I do this without creating a second list? Here is my sample
' KeyMatch is my Class Variable
' mMatchList is the Unsorted List
'
[code].....
View 3 Replies
Nov 27, 2009
I have been writing same code for insert, update, delete with LINQ over and over again. I want to have some sort of generic function for Insert, Update, Delete operation. I read a post here like the following :
public static void Insert<T>(T entity) where T : class
{
using (OrcasDB database = new OrcasDB())
[code].....
View 2 Replies
Nov 17, 2009
I'm quite new to Visual Basic - using Visual Studio 2008 and can't seem to find a way to do the following:
I have a few tables in a SQL Server database and have used LINQ to SQL to create classes of those tables.
Here's a cut down example of what I'd like:listbox1 filled with table names - APS, SMPS, WCPC, CFLAPS
Then from the SelectedIndexChanged event, listbox2 should populate column headers of the selected table.
I have no issues getting data from the database, and can access all of these headers through the anonymous type objects created from a LINQ query (eg APS.ID, APS.count etc), but populating a listbox with these variable names rather than the data inside them seems rather elusive.
This is probably a cross platform coding question rather than VB specific, so if you have a solution in C# or whatever I'd be happy if you could let me know.
View 2 Replies
Dec 15, 2010
I have an interface 'ICRUDable' and a class called ClientAddress which implements the ICRUDable interface.
My understanding of OOP would lead me to believe that if I declare a System.Data.Linq.Table(Of ICRUDable) then I should be able to put ClientAddress's in there.
The code I have tried includes;
Dim dc As New CRMDataContext
Dim items = dc.ClientAddresses
and
[Code]....
View 6 Replies
Oct 7, 2009
I recently downloaded VB2008 express. Iam trying to create a link to an SQL table, but the LINQ to SQL class is missing in my add new item menu. is there another way to grab data from a database without using the LINQ to SQL?
View 1 Replies
Jan 23, 2012
I have three tables: BOOKS(BookID, Title, Author) CLASSES(ClassID, Title, MajorID,BookID) and MAJORS(MajorID, Description). I added these three tables to a LINQ to SQL class (UBooks.dbml) and then connected to the data sources. Then declared DataContext.
Using LINQ, my goal is to display all books in a grid which I have done with:
Dim allBooks = From Books In db.Books _
Order By Books.BookID _
Select Books
Me.BookBindingSource.DataSource = allBooks
Next I need to display all majors in a listbox. I would like the description to be shown however I am only getting the majorID to display with the code
lstMajors.DataSource = db.Majors
I have tried db.Majors.Description, however I am told then that Description is not a member of the LINQ table. and my final goal is to display all the books for whichever Major is selected in another data grid. This is what I am primarily concerned with right now. When using the SQLClient classes, I was able to create a string joining the tables (also had the description properly showing in the listbox, but that is of little importance right now to me). In the video tutorials I was able to watch whenever the tables were dragged from the database into the OR designer of the LINQtoSQL.dbml class file all of the associations were already there and the narrator only really had to do some drag and drop. Not only is drag and drop not working without these associations, but I'd much rather learn the code behind it.
View 4 Replies
Feb 4, 2010
In my project I am using a LINQ to SQL class that contains a stored procedure which includes a string value as an output parameter.So to capture that, I created a string variable as follows in the procedure:Dim spOutput As String? However, when I do this I get the following message "Type 'String' must be a value type or a type argument constrained to 'Structure' in order to be used with 'Nullable' or nullable modifier '?'"
View 2 Replies
Sep 5, 2010
I have a datagridview which is bound to a local databse table through a Linq to SQL class.
Everything works as I would expect, when the application runs, up to a point.
If, in the datagridview tasks pane I enable Adding, Editing and Deleting all work as expected.
If I disable Adding & Deleting, leaving Editing enabled, Editing works as expected.
If I disable Deleting & Editing, but leave Adding enabled, Adding does not work, despite the row for new records being displayed. I can move around the row but not enter data.
I suspect somehow its the datasource as opposed to the datagridview that is the cause of my problem but as I say, I can add rows if the Enable Editing option is selected.
Changing the relevant properties programatically makes no difference.
I've been searching for the reason for a couple of days without success.
I have a workaround, by leaving Enable Editing set and programatically setting each row during the RowPostPaint event to be readonly except the row for new records. I would just like to understand what is going on.
View 5 Replies
May 26, 2012
y have this class
Private Class MyClass
Public Property propertyOne() as String
Public Property propertyTwo() as String
[code].....
View 2 Replies