C# - Use Linq To Do A WHERE Against A Collection Object (using Netflix Data Source)?
Sep 18, 2010
I am using LinqPad to learn Linq by querying the NetFlix OData source.Here is the query I got working which is awesome.[code].....
(Pardon all the comments...it is a testament to the fact I am experimenting and that I will change the query for various needs).There are two thing I cannot figure out.First.Let's say I only want to return the first 10 results.Second (and most importantly). I want to filter by a partial string of the genre.Each title contains a Genres collection. I want to show only Genres where the Name contains a certain string (like "Family").Even better filter using Titles where genre.name.contains "firstFilter" AND "secondFilter".Basically, I want to filter by genre(s) and I cannot figure out how to do it since Title contains its own Genres collection and I cannot figure out how to return only title that are in one or more genres of the collection.
View 3 Replies
ADVERTISEMENT
Jun 5, 2009
I am trying to setup a lookup combo box in my web page. I was using a linq data source but I then moved my linqtosql code to it's own class library for my DAL dll (took out of app_code folder). So, I am converting the page code to be able to still have lookups driven now by a biz object.Here's what I have done in my biz layer...
Public Class KosherTypes
Public Shared Function GetKosherTypes() As List(Of KosherTypeLookup)
Dim db As New DBDataContext
[code]....
I then setup an object data source and mapped it to this class.I have a few questions as when I was doing internet searches I didn't find anyone that seemed to be doing this and yet I know lookup tables / combo boxes are common...I went with returning a list but I could have returned an IEnumerable or IQueryable. In my reading it seemed IQueryable had more functionality for linq to sql but since I am returning a simple two column list then I only need to return an IEnumerable or List. I went with a List since it's strongly typed.
View 1 Replies
Apr 19, 2010
I have used a datarepeater with a dataset and it was simple to implement by dragging fields from the Data Sources window onto the DataRepeater control
I am trying to use Linq as a data source instead of dataset.
How do I bind data to textbox with Linq for Datarepeater?
View 1 Replies
Apr 23, 2010
how to use the VS 2010 IDE tools in a way the Microsofties didn't specifically intend. But since this is something I immediately tried without success.
I have defined a .NET 4.0 WPF Application project with a simple class that looks like this:
Public Class Class1
Public Property One As String = "OneString"
Public Property Two As String = "TwoString"
[Code]....
The expected result was that "OneString" would appear next to "One" and "TwoString" next to "Two" in the running window.
The question is: Why didn't this work? What will work instead? If I put bindings in a DataTemplate, it works. Blend, with its sample data stuff, implied that this should work, but it doesn't.
View 1 Replies
May 9, 2011
I'm creating a gridview using an objectdatasource and it works fine when pulling all records. But when I want to use the selectCountMethod the grid shows no values. I Step through the code and my getInvoices (gets the requested data) returns data and the getInvoicesCount (gets the total record count). But then when I go through the rowdatabound of the gridview there's nothing in there and no data displays. Here is my code to set the objectdatasource. Any reasons why it wouldn't work or something special that needs to be done for getting the selectcount to work? [code]
View 2 Replies
Feb 8, 2012
I like the PHP way of doing things but, it seems I am stuck with using a Collection of Object's to store/retrieve the data I need. I have my Collection loaded with my Objects's and the code to iterate through the collection, my problem is I am unable to retrieve the "key" as it would be called in PHP (I believe in this case it is actually the name of the object).
Consider the following example:
Dim xDoc As XPathDocument = New XPathDocument(fName)
Dim xNav As XPathNavigator = xDoc.CreateNavigator()
Dim sender As XPathNodeIterator
[CODE]...
As you can see, I am navigating an XML document, and creating an Object with some Key/Value pairs. The Object would look something like this if it were in JSON:
{"name":"John Smith","address1":"123 Anywhere St.","city":"This City","state":"FL"}
When I iterate though the Collection I can only get the value of the object, but I need the Key, in this instance I want "name","address1","city","state" to be stored in a variable for each iteration.
View 2 Replies
Jun 5, 2011
i'm getting error of data source object is invalid when i try to load a transaction report from sql database.
[Code]...
View 7 Replies
Oct 21, 2009
How can I convert an object of type System.Data.Linq.DataQuery to System.Linq.IQueryable?I'm working with Visual Basic/Silverlight, and the source code of my query is as follows:
Public Function Get_Cli_Pag() As IQueryable(Of V_Cliente_Pagare)
Dim Qry = From P In Me.Context.Pagares Join C In Me.Context.Codigos On C.Codigo
[code]....
View 1 Replies
Apr 15, 2009
I've got the following ADO.NET Entity Framework Entity Data Model:I want to find all the Policyholders with both a Service of a given Id and also a Keyword of a given Status.
This LINQ Does Not Work:
Dim ServicesId As Integer = ...
Dim KeywordStatus As Integer = ...
Dim FoundPolicyholders = From p As Policyholder In db.PolicyholderSet.Include("Keywords").Include("Services") _
Where p.Services.Id = ServicesId _
And p.Keywords.Status = KeywordStatus _
Select p
The Where clause cannot search the p.Services and p.Keywords EntityCollections in that way.
[Code]...
View 1 Replies
Apr 15, 2011
search the collection of a collection in my LINQ Where clause?
View 11 Replies
Jan 27, 2012
I have the following line of Dim clients = From client In db.clients Select client Where client.ClientID = id
In debugging, the clients object populates perfectly, but how can get get data from the clients object? Like if the clients object has a FirstName property, how can I set a textboxes text property to that property from the clients object?
I thought it'd be something like:
tbClientFirstName.Text = clients.FirstName But that doesn't work.
View 2 Replies
Apr 15, 2011
i created more projects using ReportViewer 2005 and 2008 in local processing mode than I can count on my hands. All Visual Studio 2005 or 2008 ASP.NET web forms projects. I always used some flavor of Object data source for the reports.Tonight, I attempted to add the same functionality to a Visual Studio 2010 MVC 2 project and am failing miserably. First, the Add New Item > Reporting > Report is now a 2008 RDLC and not a 2005 RDLC report. Secondly, when trying to add a DataSet, my usual method of create a data proxy class with static methods that return IEnumerables(Of Stuff) will not show up as sources in the DataSources drop down
Thirdly, my only option is to add a Database connection. There is no "Object Data Source" to pick from: Like I kind of alluded to, I have no problems whatsoever actually rendering a report using the ReportViewer control. What I can't do is figure out how set up a Data Source in these new-fangled 2008 reports with Visual Studio 2010 so that I can pump a list of domain objects into the ReportViewer and display the report.
UPDATE: With some more research, I've found that MVC projects do not allow object data sources to be used within them. One solution for my issue is to create a separate project in the solution -- a web application, a service, or even just a class library, to add the report to and design it accordingly.'m still looking for alternatives here, so don't run away too fast!
View 3 Replies
May 24, 2011
I am trying to find way to design a report using my own custom class. I found links:
1.) How to work in Crystal Report with Object Data Source?
2.) Use .net object as data source in Crystal Report 2008
3.) Binding object with List<> to Crystal Report
4.) How to assign Custom class as datasource in crystal report
They were quite helpful, but I have been stuck in the first step while designing report as my custom class's property is not listed in field list of crystal report design view.[code]When I add my class objects to crystal report I do not get the usertype field from users class in field list.So how can I add usertype field to my field list? Or do I have to take another approach?The reason i wanted to use it as i am:
1.) Showing a form where user can type keyword
2.) program filters the records as per keyword using LINQ
3.) when user clicks the print button, I want to set the filtered records as datasource of my report
View 3 Replies
Apr 14, 2011
Take the following scenario:
Public Class Store
Public Overridable Property Areas As List(Of Area)
End Class
Public Class Area
[code]....
What's the quickest way to get a total count of shelves for a store? I.e. for a store I get the total count of areas by using Areas.Count Or will I need to loop through each area and tally the count of shelves?
View 2 Replies
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
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
Mar 14, 2011
I want to add a "object" as a data source... then fill a "dataset" using the datasource?
View 1 Replies
Feb 10, 2012
I refreshed my data sources to include additional items from the SQL Server databases and it appears that my entire data source from my VB.NET project disappeared.I am using Entity Framework. I may have clicked on something wrong, not quite sure. Unfortunately I can't recreate the Data Source without creating a new Entity and Data Model.I can delete the entry in the App.Config file and recreated it, however things aren't quite right.Is there a way that I can recreate my Data Source from the entry that is in my App.Config file...since that appears to have remained intact.BTW, I can go to my Data Model and successfully refresh from there, however my project isn't connecting to the database so I have quite a number of errors until I can get reconnected.
View 4 Replies
Apr 7, 2009
In IE, in the View pulldown, there is an item called Source.This displays a text file of the source html for that website.I am trying to capture my Play instantly Netflix movie list so I can display movie names on my analog tv that are large enough to read from the TV.Then, with a wireless mouse in the living room, I can navigate to a movie from the tv monitor and play a particular movie.How can I save this source data as a text file on my pc?The Queue gets updated periodically and everytime I start my program, I need to capture that source.[code]but I am not getting the Source that I see when I use the IE Source menu while my Netflix Queue is display in IE.
View 5 Replies
Sep 21, 2007
Is it possible to have a texttbox autocomplete source set to a listbox's collection? I see:
FileSystem
HistoryList
RecentlyUsedList
AllUrl
AllSystemSources
FileSystemDirectories
CustomSource
in the texxtbox's autocompletesource property but are unable to make it happen.
View 3 Replies
Jun 15, 2011
I need to be able to add elements to a copy of mylist.testlist without modifying the global mylist object. (Which seems to be happening via the below code.)When I am working on x, which should be a totally separate object, mylist is getting modified as well. How can I fix this? I have worked with lists extensively and never seen this behavior before. I have tested and reproduced the problem in .NET 3.5 and .NET 4.0 on Win 7 Pro 32bit.
Source Code:
Public Class Form1
Public mylist As New test
Sub Main()
[code]....
View 1 Replies
Sep 8, 2010
Here is an example of my xml doc:
<?xml version="1.0" encoding="utf-8"?>
<employeedata>
<employee>
<firstname>Bob</firstname>
<lastname>Anderson</lastname>
[Code]...
However, only the first phone number (Office) displays in the listbox. The phoneinfo collection has both <phone> elements, but the For Each statement doesn't seem to iterate thru.
View 8 Replies
Mar 28, 2012
I have a Customer object which has a collection of ContactNumbers. Is it possible with LINQ to get a list of Customers where one of the contact numbers = '123'?
Public Class Customer
Public Overridable Property ContactNumbers As List(Of ContactNumber)
End Class
[Code].....
View 1 Replies
Oct 11, 2010
I have an Access database and I want to view on a datagridview specific rows. For that I used the following :
CasesBindingSource.Filter =
"OfferDate Between #1/1/1997# And #12/31/1997#"
Cases is the table, OfferDate a field of the table wich is DateTime type.
When I use Between operator I get the following error :The expression contains unsupported operator 'Between'.
View 2 Replies
Oct 8, 2009
I'm building flat file content from collections of strings.
Example collection: A, B, C, D, E, etc.
I want to be able to output these values to a string with line feeds in one swoop with Linq if possible.[cod]e...
View 8 Replies
Mar 6, 2012
How to get the last instance of label control in List (of Control) using linq?
View 4 Replies
Jun 29, 2009
Private Function GetWebDataGridOKButtonId() As String
Dim ctls As ControlCollection = _
WebDataGrid1.Controls(0).Controls(0).Controls
[Code]....
This is not working for me. I am trying to iterate a control collection and return one control ID.
View 2 Replies
Jun 7, 2012
On my view there is a datatable holding a collection of ServerRow and 4 textboxes (Hostname, OS, Location, Zone). When the user types into any of the 4 boxes I want to immediately filter this list. I have this code setup and ready to go that on the set method of each textbox property I call the filter method.
Now onto the problem: if I have 4 criteria that means I have 2 to the power of 4 different scenarios. What I would like to do is write a linq statement with all of these scenarios dealt with such that if any of the properties are NullOrEmpty they will not be used in the Where clause and on the flip side if there is a value the corresponding field will be searched with a Contains.
Example
AvailableCis = New ObservableCollection(Of ServerRow)
(_CiData.Where(Function(ci) ci.OS.ToUpper
.Equals(_selectedOS.ToUpper) AndAlso
ci.HostName.ToUpper.Contains(_ciNameFilterText.ToUpper))
.OrderBy(Function(a) a.CiName))
This example shows how it works with 2 criteria and both of those criteria are set.
View 1 Replies
Apr 18, 2011
Is this the most straight forward way to return a typed collection?Here's the key line of code which returns a implicit type of IEnumerable that used to manually loop through to manually recreated a TYPED collection. Is there any native LINQ way to return a typed sorted collection without this recreating of the collection? [code]
View 2 Replies
Mar 1, 2011
Can I use LINQ to return an item in a collection that is the same TYPE as the items in the collection? I am a LINQ Noob trying to avoid looping.
Dim mostRecentlyCreatedQuestionnaire As ParentQuestionnaireItem =
CType((From P In questionnaireCollection Order By P.Metadata.CreateDate Descending).Take(1), ParentQuestionnaireItem)
I get an "unable to CAST" error when I include the CTYPE function. I kind of expected that error, but I imagine that if I coul dnot do this, LINQ's usefulness would be diminished and therefore assume that there must be a way..
View 2 Replies