DataSource Controls :: Combine The LINQ Queries Together And Have Access To Both Of The Results Independently?

Feb 25, 2010

Is there a way to combine the LINQ queries together and have access to both of the results independently?


View 10 Replies

Similar Messages:

DataSource Controls :: LINQ To SQL - Multiple Queries Doesn't Return Any Results

May 25, 2010

I am working on 3.5 and in MVC using Linq to SQL classes. In my MVC project i am calling stored procedure using linq to sql that conatin query joining two tables.Below is my code in Partial class

IMultipleResults GetUserWiseThreadDetail_SP([Parameter(DbType="VarChar(30)")]
string userID)
ExecuteResult result = this.ExecuteMethodCall(this,
(MethodInfo)(MethodInfo.GetCurrentMethod())), userID);
return ((IMultipleResults)(result.ReturnValue));

In one of the controller i have made one more class

public class
IEnumerable<Thread> Thrds {
set; }
IEnumerable<Reply> Repls {
set; }
public MypostIndexData(IEnumerable<Thread>
thrds,IEnumerable<Reply> repls)

finally coding of controller action method

ForumDataContext pmforum = new
ActionResult MyPosts(string userId)
IMultipleResults result = pmforum.GetUserWiseThreadDetail_SP(userId); (this satement doesnot give any result,if i execute stored proc in
sql it give the results)
thrds = result.GetResult<Thread>();
List<Thread> thrdlist =
repls = result.GetResult<Reply>();
List<Reply> replylist;
if (repls !=
replylist = new
return View(new

I am unable to understand why i am not getting any results?

View 5 Replies

ADO.NET :: Combine 2 Linq Queries?

Jul 27, 2010

Is it possible to combine these 2 linq queries ?


View 2 Replies

Linq To SQL - How To Get Total Number Of Results When Paging Without Two Queries

Dec 29, 2010

I've got the following LINQ query to my IQueryable service

Dim eventcount = EventService.QueryEvents().Count
Dim eventlist = EventService.QueryEvents().Skip((page - 1) * 5).Take(5).ToList

But I'm wondering if there's a way to do this without making two calls to the database?

View 2 Replies

DataSource Controls :: Random Results From A LINQ To SQL Query?

Jan 23, 2010

I have this LINQ query:

var agnts = (from a in db.agents select new { a.userid, }).Take(10);

How can I get randomly get 10 records from my agents table?

I have tried:

agnts = agnts.OrderBy(n => Guid.NewGuid());

but this doesn't seem to do anything.

View 5 Replies

DataSource Controls :: Passing Results / Parameters In LINQ

Jan 20, 2010

im new to linq and im having lots of trouble creating complex queries.. My problem mainly is that i am using Linq as a BLL.

i created a dbml (with namespace called DAL) file with 2 tables with a one to many relation. Pop and City. There is a forgien key in pop that points to a city. I also created a class called Pop that inhertis DAL.Pop. Now in my ASPX page, i want to call a function in the Pop class that would retrieve some Pop according to its ID, but i need the city name as well.. Ive been going around this in circles for days. I dont know how to write the Linq syntax and i dont understandd how my function's signature should be like.. I want to recieve a table that i can bind to a Gridview and preferable, specify which coloumns to bind.

View 2 Replies

DataSource Controls :: Linq To SQL Return All Results / Wild Sign?

Feb 2, 2010

I've been reading around, and it sounds like this is somewhat common, though I'm missing something.

I have my filtering rerouted to my codebehind via DataGridSource_Selecting event handler per

I have a set of controls on my page, Start Date, End Date, User, Status

Start and End Date are expected to always contain a value

User and Status I want to also have an 'All' option, where in it would return all results/not filter.

One method I can think of using for this, is the put the queries in a If scenario, where

if(user == All), use linq query B
if(user != All), user linq query A

where linq query A contains the filtering on Users, and linq query B does not.

What I have so far is


What I need


where User == ??,

can the control that populates that contain a wild card option as well? ie *, so that if user == Name, it filters on Name, or if user == *, it returns all?

View 2 Replies

SQL Server :: Combine Two Queries In One Resultset?

Sep 6, 2010

I want to combine two queries like :

select name as name1 from table1 where id = 6


select name as name2 from table1 where id = 2.

I need a single resultset. How can I do that?

View 26 Replies

SQL Server :: Combine Two Self Referencing Queries In A Function?

Feb 23, 2011

I have a menu table which has a (mostly) unlimited number of levels/tiers:


I also have a working function which will give the up and down tiers based on a given MainMenuId:


My question is, is there a better way to do this such as combining the two querries? Every attempt I have made results in a "The Statement terminated. The maximum recursion 100 has been exhausted before statement completion"

View 4 Replies

DataSource Controls :: LINQ To SQL VB- Read Only Access?

Mar 29, 2010

I'm have two problems that I would appreciate feedback on:1. I added new fields to database, store procedure, and dataContext but the data Context is not showing up when I select the datasource in the Grid control.2. I have dbo access to the database but have read only access. When I add a grid to the app I only have the option to sort, page, select.

View 1 Replies

DataSource Controls :: Data Access Repository NO LINQ?

May 18, 2010

I am new to MVC and this really probably should not be posted here but in a different forum topic. The reason I am posting here though is I am not sure if there is something about MVC that would prevent me from doing what I am looking to do.So here it goes.Maybe I am the only one out there that thinks this way but I don't care for and don't fully understand LINQ. I Like building my stored procedures passing my data to a datareader etc... and displaying what I need.

Now that being said I am wanting to learn how to make a true Data Repository and build from there but everything I find online especially here all gives me examples and instructions on how to do so using LINQ.Does anyone know of a site that will teach me how to do this without using LINQ or any form of ORM just allow me to write my stored procs how they need to be and build my classes for data access how they need to be.I may be wrong in this but it seems to me this would be the more light weight way of doing it.Anyhow as stated above the additional question to this would be is there any reason this would not work for MVC and actually any reason it is extremely (or at least for me) hard to find any documentation on this anywhere online?

View 3 Replies

Entity Query - Combine Into One And Avoid Merging The Results

Nov 6, 2010

I can't seem to figure out how to write this query properly. I've tried various combinations but nothing's worked yet. Below is the relevant portion of my database model: I need to select the products that match a given Category and Group, and that match a given Year, Make, Model, submodel. This I've done below:

ItemList = From P In gDataContext.Products.Include("Groups").Include("Groups.Category1").Include("LookupYearMakeModels") From G In P.Groups Where G.Category = Cat And G.Grp = Group From Y In P.LookupYearMakeModels Where Y.Year = YMM.Year And Y.Make = YMM.Make And Y.Model = YMM.Model And Y.Submodel = YMM.Submodel Select P

I now also have to select products that match the Category, and Group but are Universal (Product.Univeral = True). I'm currently writing two queries, the one above and the one below. I'm merging the results of the two by simply using ItemList.AddRange(ItemList2) ItemList2 = From P In gDataContext.Products.Include("Groups").Include("Groups.Category1") where P.Universal From G In P.Groups Where G.Category = Cat And G.Grp = Group Select P But I want to combine both queries into one and avoid merging the results. How can I do it?

View 2 Replies

DataSource Controls :: Combine Data From 2 Tables

Mar 27, 2010

I have 2 tables with UserId and FirstName, LastName Columns that I want to combine the data in a Select Statement or Stored Procedure

1. The 2 tables will never have the same data, each table will be distinct

2. I want to combine first and lastnames to a full name (t1.FirstName + ' ' + t1.LastName) AS FullName

3. The statement will be used to populate a dropdownlist with UserId as Value, and Name as text

I am unsure how to accomplish this since I do not need to connect the tables, but combine the Sum of their data.

View 6 Replies

DataSource Controls :: Combine 2 Datatables From A Webservice?

Jun 23, 2010

The case is: I use a webservice that gives me information about companys. For example: I entered a companyname and the webservice give me a list of al company's in the country. The webservices return a one dimensional array. The problem is that I must search in two register so the webservices returns 2 array's. I put the data from both arrays into 2 datatables. The data in the 2 datatables can be different or the same.

The question is: How could I matching the data on ID and combine the data into 1 datatable.

The code:

//Create result
SearchResult Result1;
SearchResult resultZoekmogelijkheid2;
//send van Soap Request


View 7 Replies

ADO.NET :: Can't Combine "LINQ Join" With Other Tables?

Jan 8, 2011

The main problem is that I recieve the following message:

"base {System.SystemException} = {"Unable to create a constant value of type 'BokButik1.Models.Book-Author'. Only primitive types ('such as Int32, String, and Guid') are supported in this context."}"

based on this LinQ code:


How shall I solve this problem to get a class instance that contain with property title and Book-AuthorID?I also have tried making some dummy by using "allbooks" relation with Code Samples from the address Unfortunately, still same problem.

I also have taken account to Int32 due to entity framework Unfortunatley, still same problem.

Using database with 3 tables and one of them is a many to many relationship. This database is used in relation with entity framework

Book-Author (int)
BookID (int)[code]....

View 1 Replies

Forms Data Controls :: DataList No Results / Access Datasource On The Page With A Datalist To Show The Data?

Nov 15, 2010

The problem is that i have a search page. Access Database holding the information. I have a Access Datasource on the page with a Datalist to show the data. I need to find a way on setting it up to says "Sorry no results found" when the is no results. i am unsure on how to do this though.

Below is my datasource and datalist


View 6 Replies

DataSource Controls :: Statement To Combine Columns Of Different Tables

Feb 4, 2010

I have 2 tables and I want to entries of the tables into something like this:

Table 1: Table 2: End Result:
a 1 a - 1
b 2 a - 2
... ... b - 1
... ... b - 2
... ... ...

View 3 Replies

DataSource Controls :: Combine Two Result Sets From One Table?

Jan 6, 2010

I have a table that contains a date column along with others. I need to extract two sets of data from this table for two different time periods. Call them Current and Previous, so that I can compare them line for line. There are exactly the same number of days in both time periods.

The problem is that I need to return the data like this:

CurrentDate, Count(CurrentItems), Sum(Amt), Count(PreviousItems), Sum(PrevAmt)

JOIN puts the data into the result vertically, so that doesn't work. So far, I have not found a method that will arrange the data correctly.

View 1 Replies

DataSource Controls :: How To Write SQL Queries

Mar 5, 2010

SELECT 1000000*QuantityNC/Quantity AS PPM FROM [table1] However I need my WHERE clause to do thisI need the above calculation depending on BusUnit, which is linked to PartNumber, which is in the above table. also it has to be by Company (which is selected from a dropdown). And also based on the current month and year.

PartNumber and CompanyName are in [table1]
BusUnitID, PartNumber, SupplierID, are in tblParts
BusUnitID and BusUnit are in tblBusUnits

View 2 Replies

DataSource Controls :: Run Queries From Website?

Jun 28, 2010

I need to fire sql queries in my website and get the results from the Database. for example: I will give select * from emp in a text box. It shud return the results for me. DO any of u have a sample/links of such application, through which i will be able to implement in my application share me the links/sources/app if u have any.

View 2 Replies

DataSource Controls :: Combine Multiple Columns Into One For Select Statement?

May 14, 2010

This question is for wrapping up work on a database driven AJAX AutoComplete Control that I am using to provide keyword hints to user on search pages. Each record has 6 columns for keywords where each column is for an advertiser to add a keyword. These are used in meta keywords tags, but I also want to use them for AutoComplete. The problem is that I don't know how to write a SELECT statement in Visual Studio that treats all 6 keyword columns as if they were all one column. I am looking for something like

SELECT (keyword1 + keyword2 + keyword3) AS Keywords
FROM (Merchandise)
WHERE Keywords LIKE @term

The only other thing I can think of the gain this level of functionality would be to combine them into a new table.

View 7 Replies

Access :: Parameterized Queries With Optional Parameters (Access DB)?

Aug 13, 2010

so I have a web programming assignment for university where I'm building a website that uses an Access database but I have hit a brick wall with something.I'm using parameterized queries to query my database. For one of my queries, I want to be able to take a bunch of parameters that are optional, and if they aren't needed I'll pass in a value of null and I'd like the part of the where clause relevant to them to evaluate to true. This is straightforward in most databases, from my understanding you could do something like to make param1 an optional parameter.

WHERE ((@param1 = ARandomColumnName) OR (@param1 = null))

However this can't be done using Access, as all parameters in a query are represented by a ?. Every ? is assumed to refer to a different parameter, so if you want to use a parameter more than one (like the above code I wrote does) then you'd have to pass it twice. This seems hacky to meSo what do I do? I have spent *hours* googling and banging my head on the desk. I'll cry if I missed something really obvious

View 2 Replies

MVC :: Linq - Use Normal Sql Queries?

Jan 11, 2011

When i see MVC Music store. They have used ADO.NET entity data model and used LINQ language to perform operation in DB.. Is there any way to use normal sql queries?

View 3 Replies

ADO.NET :: Converting SQL Queries To Linq?

Jul 31, 2010

How to convert SQL Queries to their any tool available to convert SQL Queries to Linq

View 2 Replies

C# - Difference Between These LINQ Queries?

Mar 18, 2010

I use LINQ-SQL as my DAL, I then have a project called DB which acts as my BLL. Various applications then access the BLL to read / write data from the SQL Database.

I have these methods in my BLL for one particular table:

public IEnumerable<SystemSalesTaxList> Get_SystemSalesTaxList()
return from s in db.SystemSalesTaxLists
select s;
public SystemSalesTaxList Get_SystemSalesTaxList(string strSalesTaxID)
return Get_SystemSalesTaxList().Where(s => s.SalesTaxID == strSalesTaxID).FirstOrDefault();


View 2 Replies

Copyrights 2005-15, All rights reserved