LINQ To XML Result Object Not Showing Extension Methods

Jan 9, 2012

I have the code as below:
Dim xdTest As XDocument = XDocument.Load(GetXMLPath())
Dim objResult = From xe In xdTest.Elements("Some Element") _
Where xe.Element("strName").Value = strInput _
Select xe.Element("intValue").Value
objResult.
I cannot access any extension methods for objResult, like .ToList() or .First(). The file imports System.Linq and the project is targeted to .NET 3.5. How do I get the extension methods back?

View 1 Replies


ADVERTISEMENT

Extension Methods For Object

Nov 9, 2011

I wonder why it's impossible to create and extension method for Object? I use Excel PIA. The property Cells of Worksheet returns Object (if using with indexes). For example, Worksheet.Cells(1, 1) returns Object type. I know it's a Range object, and I want to cast it to Range. It would be convenient to write following:[code]

View 5 Replies

.net - Using Extension Methods From Within An Object's Constructor?

Feb 8, 2010

Consider the following:

Public Module Extensions
<Extension()> _
Public Sub Initialize(ByRef Target as SomeClass, ByVal SomeParam as Something )

[code].....

Why is Case 1 failing to initialize the object as expected?

View 1 Replies

End Result Of Combobox Selection Keep Showing Same Multiple End Result When There Is Only One Entry?

Dec 10, 2010

I am currently having a headache on how to solve this problem that i am facing. here is the situation: I have a combobox and a list box on the main form. The combobox will get the data from the ms access database. In the database, i have the details of a person's IC, Name and DOB say for eg on one entry I have D215311523C,SHAWN,13/04/1987 So now, my combobox on form load will show the list of dates in the database to allow the user to search base on the date itself by clicking on the selected date. So when the user clicks on the particular date say 13/04/1987, people in the database whose birthday is 13/04/1987 will be shown on the listbox.Meaning to say if i have 3 entries whose dates are the same 13/04/1987, 3 entries will appear. If there is only two entry, then two results will be shown. But now, when i do a single click on the date, one result will be shown. That is correct. But the problem is when i click on the same date again, three of the same results will be shown on the list box. that is it will display : 13/04/1987 13/04/1987 13/04/1987 which is not the case. Then it will show more duplicates of the same results if i click more times on the same date which should not be the case.

Dim n As Integer
Dim numbers() As Integer
Dim StartFrom As Integer
Dim EndAt As Integer

[code].....

View 3 Replies

.net - Extension Methods In T4?

Mar 28, 2012

I'm trying to use PGK.Extensions in a T4 template in VS2008 for VB.NET and I get:

RemoveAllSpecialCharacters is not a member of string..

My T4 headers:

<#@ template language="VB" hostspecific="false" debug="true" inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>
<#@ output extension="vb" #>
<#@ assembly name="PGK.Extensions.dll" #> // the dll is found
<#@ import namespace="StringExtensions" #> //Try with and without namespace

[Code]...

View 1 Replies

Why Use Extension Methods

Jan 7, 2010

I would like to know your opinion on extension methods. Sure, it is a nice feature and makes you feel powerful. It's great to see your own method pop up when typing in a object. But it doesn't really add something new... You can get the job done with normal methods as well. I think extension methods do not belong in object oriented programming. It makes your code easier to read but harder to understand for someone else.

View 2 Replies

.net - Extension Methods Error ?

Mar 7, 2011

CODE:

View 2 Replies

Asp.net Mvc - Combining Extension Methods?

Sep 5, 2009

I'm trying to write 2 extension methods to handle Enum types.One to use the description attribute to give some better explanation to the enum options and a second method to list the enum options and their description to use in a selectlist or some kind of collection.You can read my code up to now here:

<Extension()> _
Public Function ToDescriptionString(ByVal en As System.Enum) As String
Dim type As Type = en.GetType
Dim entries() As String = en.ToString().Split(","c)

[code]....

So my problem is both extension methods don't work that well together. The methods that converts the enum options to an ienumerable can't use the extension method to get the description.

View 1 Replies

How Do Extension Methods Really Work

Jan 25, 2010

I know what extension methods are, how to create and use them, but I wanted to know more about how they actually work. How do they "attach" themselves to the type of object that you are extending? Or is there even an attachment being made. I know want to know more about the inner workings, etc.. I looked around and read several different blog posts about extensions and not one of them discusses how they actually work.

View 6 Replies

.net - Extension Methods In Referenced Assemblies?

Sep 16, 2010

If I try to call my extension method which is defined like this:

Module LinqExtensions
<System.Runtime.CompilerServices.Extension()> _
Public Function ToSortableBindingList(Of TSource)(ByVal source As IEnumerable(Of TSource))

[code].....

View 1 Replies

.net - Syntax And String Extension Methods

Aug 30, 2011

Code in VB.NET

[Code]...

works very well. So seems some consistency miss of the string constant behavior.

2) Have a look on the COMMENTS (in the attached picture). The words "custom", "string" and "error" are highlighted, however they are in the comments, so should be green, not blue.

Why this? What workaround? EDIT: Declared as "bug" in Microsoft Connect (even if is not more that a syntactic "miss")... EDIT 2: As remarked Hans Passant, standard string methods, like "cucu".Trim() does not work either.

View 2 Replies

How To Know If Class Has Been Extended With Extension Methods

May 30, 2012

In VB.NET or C#, is there a way to determine if a class has been extended with extension methods?

View 3 Replies

Way To Add An Overload To A Method That Already Has One Or More Extension Methods?

Jan 8, 2010

Is there anyway to add an overload "extension method" to a method that already has one or more extension methods?For example theString.Contains method has two extension methods totalling 3 separate versions.Is there anyway to add an extra extension method also called "Contains" ?By the way I have tried it but the IDE does not seem to recognise additional EXTENSION methods where a method already hasone or more extension methods.Is there anyway around this restriction?In other words I would like to be able to change the Extension method below from"Contain" to "Contains" but it seems it is not recognised.

Option Strict On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

[code].....

View 4 Replies

Cant See Available Methods List When Write Object.METHODS?

Jun 24, 2011

I am working with a vb program, but there is something strange on one of my .vb code pagewhen i put the "dot" afther the object name its dont show the methods availables for this objectbut on other vb code pages i can see it. but in this one no.for exmaplethis is a piece of code: Dim sb As New StringBuilder()

View 3 Replies

.net - Extension Methods From C# Dll Doesn't Work As Extensions?

Sep 17, 2010

I made a library in C# and I've been told by people that one of mine methods don't work in VB.NET as extension [UR]

this is the method:

public static PropertyDescriptorCollection GetProps(this object o)
{
return GetProps(o.GetType());
}

View 1 Replies

.net - Extension Methods In VB 2008 Assembly Cannot Be Used In A C# Project?

Jun 1, 2011

I wrote some string extension methods in a VB assembly and am unit testing them from a C# project. However, C# acts like it cannot see the the extension methods, when other VB projects reference the VB assembly they have no problem. Both the VB assemebly and the C# test project are targeting .Net 3.5. Is there a way around this?

[Code]...

View 1 Replies

Extension Select Methods For Entity Framework?

Dec 14, 2011

I have many similar calls to database and they work fine

Using ta As New QT_SSTEntities
Return ta.Product.
Select(Function(c) New RadComboBoxData() With {.Text = c.FieldName1, .Value = c.FieldName1}).

[Code].....

View 1 Replies

.net - Check That Extension Methods On An Array Got A Specific Size?

May 30, 2012

I'm using extension methods based on an array and I would like to know if there is an easy way to check that array got a specify size instead of me doing a copy paste of

if array.count != 1000
throw new exception "size of the array does not match"
in about ~50 extensions

this a small sample of extensions that I use, I got WAY more

<Extension()>
Public Function IsWhite(ByVal board() As bitPiece, ByVal pos As Integer) As Boolean
Return (board(pos) And bitPiece.White) = bitPiece.White
End Function

[code]....

View 3 Replies

Doesn't C# Extension Methods Allow Passing Parameters By Reference?

Aug 11, 2009

Is it really impossible to create an extension method in C# where the instance is passed as a reference?

Heres a sample VB.NET console app:
Imports System.Runtime.CompilerServices
Module Module1

[code].....

View 3 Replies

MVC2 Extension Methods Throwing Errors In Views?

Nov 21, 2011

I have a project written in MVC2 and VB.NET. I use a lot of htmlhelper extension methods,and I have them all in a public module. They work just fine, and I can compile and run my project. I reference the namespace they are in with this:<%@ Import Namespace="MyProject.WebUI.Extensions" %>So, again, they work great, my project runs and compiles without a hitch.The problem is that each one of these extension methods is shown as an error:

Error 33 'TabbedMenu' is not a member of 'System.Web.Mvc.HtmlHelper(Of Object)'. C:ProjectsMyProjectMyProject.WebUIViewsSharedSite.Master 23 21 MyProject.WebUI

[code]....

View 2 Replies

Silverlight - Useful Extension Methods In System.data.* Namespace?

Nov 21, 2011

I have a number of very useful extension methods that I'd like to use in my Silverlight project.I've pasted the Module here [URL]The problem I'm having is that visual studio complains that the dlls my module have been written against have not been built against the Silverlight runtime.Is there an easy way to get these extension methods working in Silverlight?I'm thinking my main hurdle is getting IObjectSet and ObjectContext to run against the Silverlight run-time - perhaps there's another way to expose these methods that I'm not aware of.

View 1 Replies

Difference Between The Following Methods Of Showing Forms?

Jul 26, 2011

What is the difference between the following two statements (in terms of memory management):

Dim frm as New MyForm()
frm.Show()
VS
MyForm.Show()

I am originally a C# developer, how does the second one make sense or even compile for that matter in VB.NET? (Show() is not a Shared/Static method) What is happening in the second case?

View 1 Replies

Asp.net - Why Is FileInfo Showing An Extra File Extension

Sep 6, 2009

I have been having problems with creating a download list of files for a downloader and was getting unexplained "File Does Not Exist" returns. My .avi files were returning found but but .exe and .txt files were getting the not exists.

I have now found by pulling in the whole directory and examining the file contents that my .exe files are showing ".exe.exe". My .txt files are showing ".txt.rtf". Wow, browsing the file directory in Server 2008 only shows a single extension. I don't see an option to display the extension as a column, just the "type". My directory looks like this:

Name Type
File1.exe Application
File2.txt Rich Text Document
File3.avi AVI File

I had renamed some of these files, maybe I just cannot rename files. I will try using originals ans see if I am ok. Maybe I need to rename the offending files without the displayed extensions. Is this just something weird with the server browser?

View 2 Replies

Constructor String - Create An Object And Use The Object To Display All Methods

Sep 21, 2009

Under component services, a COM+ component is used by the company, right-clicking it and choosing 'Activation' tab will show the 'constructor string' that is used for DB server connection by all applications. How can I access it the simplest way possible?

[Code]...

View 1 Replies

Delay In Showing Result

Sep 4, 2009

I have 3 file to compare.[code]Now my problem is it take more than 1 minute to show the output which is very late. I dont know where i did wrong.

View 1 Replies

Forms :: Showing A SQL Result

Aug 18, 2010

I have the following code in my project:

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String

[Code]....

I'm needing to do is to show in my messagebox.show the date from the sql query that I ran before this. I know that I havent declared a variable in that statement but I'm having a bit of a lapse today and was just wondering how to show that result in my messagebox.show.

View 19 Replies

Showing A Sql Query Result?

Mar 16, 2010

I have the following code in my project:

rivate Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String

[code].....

View 18 Replies

Showing Query Result In CheckedListBox?

Feb 15, 2012

I'm trying to show some concatenated data in a CheckedListBox so that users are able to select the data for use later on. Here is the code I am using currently:

Dim con As New MySqlConnection
Dim theQuery As New MySqlCommand
Dim theTables As New DataTable

[Code].....

View 2 Replies

Showing SQL Query Result In Message Box

May 25, 2011

Is there a way to show the value retrieved by an SQL statement in a message box? In context, my SQL statement searches my database to find a customer record that matches the details entered into the text boxes on the form, and retrieves the CustomerID. Is there a way to show this CustomerID in a message box?

The SQL code is:
SELECT customerid
from customer
where cust_forename = @custforename and cust_surname = @custsurname and cust_house = @custhouse etc

View 14 Replies

Result Variable Of Records Instead Of Showing Only Query?

Apr 29, 2011

Private Sub cmdLogin_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdLogin.Click
Dim conn As MySqlConnection

[Code]....

i supposed it can show the result of count(ID), in this instant it is the number of records count on the OUTBOX so the debug.writeline is RESULT, instead of now it is showing "SELECT COUNT(ID) FROM OUTBOX"

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved