Creating A Reference To An Object In An IEnumerable Linq Query Would Be Really Slow?

Jun 18, 2009

Is there any particular reason why creating a reference to an object in an IEnumerable Linq query would be really slow? I have a Linq query list consisting of my own objects (count is about 200).I was doing a time-critical task, and this line (which was used a lot in a loop) took nearly a millisecond to execute:

Dim CurObject as MyClass = QueryResult(CurIndex)

View 2 Replies


ADVERTISEMENT

.net - Linq Query Not Returning IEnumerable?

Jan 22, 2010

I have the follow Linq query that is in a web application that was converted from .NET 1.1 to 3.5:

dim objListOfFilteredDataRows = from datarows as datarow in objDataSet.tables(0).rows _
where datarows("SomeColumn") = SomeValue

I have the exact same query in an application that was created using .NET 3.5 and the query returns an IEnumerable. However the query in the converted application is returning:

{Name = "WhereEnumerableIterator`1" FullName = "System.Linq.Enumerable+WhereEnumerableIterator`1[[System.Data.DataRow, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"}

**Edit: When I highlight the expression, the intellisense says that it doesn't know the type of objListOfFilteredDataRows and assumes its a type of "Object". Why is the type not infered in the converted 1.1 application but is infered in the "native" 3.5?**

What am I missing here? How do I convert the "WhereEnumeratorIterator`1 to an IEnumerable?

View 5 Replies

'Object Reference Not Set To Instance Of An Object' While Creating Pivot In Excel

Jun 23, 2012

I'm trying to create a pivot table by opening an Excel file from my drive.But I'm receiving the error saying "Object reference not set to an instance of an object".[code]

View 1 Replies

Error - Creating The Form - Object Reference Not Set To An Instance Of An Object

Apr 13, 2012

I'm having this problem with my code and cannot seem to get past it although it was working fine before. The error is "An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object." The code is:

CODE:

I am trying to get information to be pulled out of a database and show in text boxes on another form (frmviewsdets). The error occurs when it gets to the line frmviewsdets.txtsnumber.Text = rdr("StudentNumber") and even when a breakpoint is applied there it just moves on to the next and so on.

I have tried to show frmviewsdets before I pull the data out of the database beut I get the same message.

View 14 Replies

C# - Linq To XML Query Creating Empty Items From XML

Feb 15, 2010

why is this xml

<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="77" cityID="EE12345" cityDatum="15.2.2010. 11:28:35" />
</items>

[Code]....

If you, as some can't replicate these results, here's a screenshot:

View 1 Replies

Creating Object Defined In DLL With No Reference

Jul 23, 2010

I have the full path to a dll, but not a reference, where I need to instantiate an object that implements an interface that I've defined. I do have control over the other dll, so I am able to do things like stick a static function in the dll that returns the object I need. I'm just not sure how to call that function, or even if I'm approaching this right.

View 3 Replies

An Error Occurred Creating The Form. See Exception.InnerException For Details. The Error Is: Object Reference Not Set To An Instance Of An Object?

Apr 30, 2009

WTF, here's my code...

Public Class Form1
Dim BIT01 As Integer = BIT_01.Text
Dim Value As Integer = TB_OutPut.Text

[code].....

View 1 Replies

Asp.net Mvc - Creating A List (of String) Giving Error" Object Reference Not Set To An Instance Of An Object"

Nov 1, 2011

MVC 3 razor VB.NET project. I have resorted to manual building a list for a drop down box so I can insure certain values are available in the select list and also to control what the first item is in the list. The below is my code snippet for the part that is giving me problems..

[Code]...

View 2 Replies

How To Write This Into Linq To Object Query

Feb 24, 2010

from a list, which got 3 attributesI want to return a new list of that class where attribut1 recurrence in the list equals Xfor an example this;

1,a,b
1,c,d
1,e,f

[code]....

View 3 Replies

LINQ To SQL: Reference The Data Context When Extending A Table Object?

Jul 27, 2009

If I'm extending OnCreated for a LINQ to SQL table object, is it possible to get a reference to the data context to which the table belongs? For example, if I add a property to the data context:

Partial Class MyDataContext
Private _myValue As String
Public ReadOnly Property MyValue As String

[Code].....

I don't want the property on the data context to be Shared, because it could be different per instance. I've been pouring over the designer code to figure out where the reference might be, but no luck yet.

View 3 Replies

C# - LINQ Query On Object With Unknown Class

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

LINQ To Objects, Query Arrays In Object?

Sep 15, 2011

I need to query an array. I have tried to use LINQ but with no success.

Here is a simplified structure of Insurance

Public Class Insurance
Public _typ As String
Public _numb As Number()

[Code]....

View 1 Replies

Determine The Type Of Object To Use To Store A Linq Query?

Jul 3, 2010

I am using VB .Net for this, so I don't have access to var or this would be a simple matter.Right now my query is as follows

[code]...

So I used this query in LinqPad to help me determine what the object would look like. I got back a IOrderQueryable(Of RSError) which then contained a IGrouping(Of String, RSError) for each grouped collection of objects returned by the query.However I ended up with the current object type of errors as IOrderedQueryable(Of IGrouping(Of String, RSError)) because of the cast error I am getting in VS.

[code]...

I'm not sure how to get rid of the VB$AnonymousType_1 Part of the returned object.Am I even on the right track here or am I missing something completely?

View 1 Replies

LINQ - Query Children Object If Parent Count Is = 1

Apr 17, 2012

I have a the following Class structure. Company > List(of Departments) > List(of Employees) I want to Query a Company to find out if it has a department of the following name and a Employee in that department with the following ID! How could I query this. The way I have the code it expect to return one department so I have it doing

[Code]...

View 2 Replies

VS 2008 Xml Document Would Be Taken From The Web And Stored Into An XDocument Object / Linq Query

Jul 27, 2010

I have the following xml document which would be taken from the web and stored into an XDocument object.

[Code]...

View 3 Replies

LINQ Query To Group Data Between Two List Collections, Populating A Nested Object

Oct 26, 2011

I have these objects:[code]Using LINQ I need to take a List(Of MakeInfo) and a List(Of ModelInfo) and aggregate the StockInfo from ModelInfo into the List(Of MakeInfo).So for each MakeInfo I will have a total count of all stock where MakeInfo.Name = ModelInfo.Make, and also a minimum price.I think it's going to be something like this, but I'm having trouble accessing the nested object and not sure if it's going to be possible with a single query.[code]

View 2 Replies

.net - LINQ - IEnumerable.Join On Anonymous Result Set?

May 28, 2010

I've long since built a way around this, but it still keeps bugging me... it doesnt help that my grasp of dynamic LINQ queries is still shakey.

For the example:

Parent has fields (ParentKey, ParentField)
Child has fields (ChildKey, ParentKey, ChildField)
Pet has fields (PetKey, ChildKey, PetField)

[Code].....

The above Join call doesnt work. I sort of understand why it doesnt work, but hopefully it'll show you how I tried to accomplish this task.

After all this was done I would have appended a Select to finish the job.

I tried it with the PredicateBuilder with little success. I might not know how to use it right but it felt like it wasnt gonna handle the joining.

View 1 Replies

IEnumerable.where In Linq How To Get Obj&return Value Of Othr Func

Apr 4, 2012

How to give another function's returned value in LINQ Ienumerable.

Private function GetFruitColor(fruit) as string
'It returns fruit color.
'If valid fruit and color not available, it returns ""(empty string)

[code].....

'Below code is wrong. but please suggest me how to correct it. My intention is, I want output collection(say dictionary) of each fruitname and its color(returned by other function call) for all the fruits which the GetFruitColor is not nothing(it can be empty or valid string).

Dim query = _
fruits.Where(Function(fruit) k= GetFruitColor(fruit) if not k is nothing select fruit, k)
End Sub

View 8 Replies

C# - LINQ Select From IEnumerable With Distinct/GroupBy And Sorting?

Oct 19, 2010

My particular example is fairly complex but I think the concept would apply equally to something like a logging system so I'll use that instead for ease of explanation. It's a ficticious example, please don't harp on or agonise over what is achitectually, programatically or morally wrong with the example itself

[Code]...

I don't want to 'cheat' and resort to a long-winded way of doing it when performance isn't critical here and I'm moderately confident it can be done in a single LINQ statement.

View 1 Replies

Working With System.collection.generic.Ienumerable/XML Linq Queries?

Oct 22, 2009

This is really a continuation from my earlier post. I've never worked with this datatype/collection (system.collection.generic.Ienumerable) before so I'm struggling to declare the query globally so I can reference the results within other sub routines/functions. I also am struggling to convert it to other types.how I can convert the collection of xml elements/system.collection.generic.Ienumerable into an xmltextreader (I know I will have to change the query below as it select the value of the node and not the node itself) I imagine by converting the query result to system.IO.stream My first port of call was MSDN but I find the material very difficult to understand for this particular subject.

[Code]...

View 3 Replies

Implement The .Find Method When Binding A BindingSource To LINQ (IEnumerable) Result?

Mar 15, 2008

I'm binding a DataGridView to a BindingSource to a LINQ IEnumerable, I found that the BindingSource.Find method throws an exception because .Find isn't implemented in IEnumerable (and the BindingSource just passes the call to it's DataSource). I need to use BindingSource.Find to select/highlight a particular row in the DataGridView.

Is there a feasable way to extend my DataContext to support this behavior w/o breaking anything else? I expected to find the code out there already, but I've searched exaustively with no luck.Without it, I cannot "move" the BindingSource using .Position and that's a pretty common use of the BindingSource I think.

View 1 Replies

LINQ Query Is Enumerated - Turn On Some Kind Of Flag That Alerts Me Each Time A LINQ Query Is Enumerated?

Sep 22, 2009

I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens.Certainly in a For Each loop, the query would be enumerated.What's the rule of thumb to follow? I don't want to accidentally enumerate over my query twice if it's a huge result.

For example, does System.Linq.Enumerable.First enumerate over the whole query? I ask for performance reasons. I want to pass a LINQ result set to an ASP.NET MVC view, and I also want to pass the First element separately. Enumerating over the results twice would be painful.It would be great to turn on some kind of flag that alerts me each time a LINQ query is enumerated. That way I could catch scenarios when I accidentally enumerate twice.

View 3 Replies

Creating A Gridview And Gather The Data From Various Functions That Return A Type Of IEnumerable?

Feb 28, 2012

I am creating a gridview and need to gather the data from various functions that return a type of IEnumerable. I've created gridviews using a dataset as a datasource, but how does one use multiple data sources(of IEnumerable) to populate one gridview? Like how do you combine all that into one dataset?

View 1 Replies

"Object Reference Not Set" Error When Creating A Form?

Apr 12, 2012

I got this error when running my program. I wasn't like this before when I'm creating this program.

An error occurred creating the form.See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.

[code]...

View 1 Replies

C# - Convert Datatable To IEnumerable<T> To Pass To Result<T>(IEnumerable<T> Data);?

May 9, 2011

I have an object called Result<T> that has a constructor which accepts an argument of IEnumerable<T>. I'd like to be able to pass in a datatable if possible.

I tried datatable.AsEnumerable(), but where I bind to the data it was complaining that 'MyProperty' is not a field or property on type 'DataRow' - which makes sense since 'MyProperty' isn't a property on 'DataRow', but it was a column in my datatable.Is there a way to convert a datatable to something that I can pass into the Result object and still have it bind to, say, a gridview?

View 3 Replies

.net - Transpose 2D Array That Exists As IEnumerable Of IEnumerable?

Dec 16, 2010

I tried using the linq Zip method on IEnumerable but it does not work for more than 2 arrays.Here is an example in Python of what I am trying to do(I got p - nested IEnumerable - and need q - another nested IEnumerable):

>>> l=['a','b','c']
>>> m=[1,2,3]
>>> n=['x','y','z'][code].......

View 2 Replies

Cast A Reference To An Object To A Reference To An Object Of The Same Class?

Mar 17, 2012

The book "Beginning ASP .NET 4 in VB 2010" contains the following:NOTE: TaxableProduct inherits from Product.You can also cast in the reverse directionfor example, cast a Productreference to a TaxableProduct reference. The trick here is that this

View 2 Replies

Slow DAO Query In Windows 7?

Oct 5, 2010

We use DAO 3.5 and we are seeing delays on some queries on windows machines 7.

The database is on a windows server 2008.

The query is a join between two tables and contains an ORDER BY.

The query execution is very slow.

If we remove the join or order by the query execution is fast.

Is there an incompatibility between Windows 7 and DAO 3.5 ?

View 1 Replies

Linq To SQL Transaction Insert Then Select Really Slow

May 25, 2011

I'm developing a piece of a system that basically migrates data from one set of tables to another set. Everything works fine, but I've decided to employ transactions instead of just failing on things that are partially completed. (That is, if some exception occurs, I want to rollback instead of having partial data migrated.)

I have a service (in the 3-tier architecture way, not web) which begins a transaction on the data access layer. The data context is shared in the data access class which contains many methods. Those methods use various LINQ-to-SQL techniques to update/insert/delete. All the LINQ-to-SQL "selects" are within CompiledQueries. [code]...

View 1 Replies

VS 2010 Getting Started With Linq, Code Is Very Slow?

Oct 19, 2011

I am using DataSet.ReadXml() to create a DataSet from the following XML file, so that I can quickly query it using Linq.[URL]..I then use the following object to create a DataTable which can be used as a dictionary, with a ConvertToFriendlyFormat function that takes an Emulator_Id and and a string that corresponds to a DicEntry node's StoredFormat attributed, and return the same node's FriendlyFormat attribute.

This does work BUT it is extremely slow (~11 seconds to call it ~220 times). I have been unable to figure out how create the DataSet when the object is initialised and just query the simple DataTable in the ConvertToFriendlyFormat call. I guess this is what is slowing it down?

[Code]...

View 4 Replies







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