ADO.NET :: Linq Multiple Where From Second Table
Dec 16, 2010
Tables:
WORKORDER and CUSTFIELD
Fields:
WORKORDER = WORKORDERID
CUSTFIELD = WORKORDERID, CUSTFIELDNAME, CUSTFIELDVALUE
There are multiple different type of name/value pairs. I want to specifically return the custfield value where custfield name is "INCIDENT", and the custfield value where custfield name is "NETWORK" all for the appropriate WORKORDERID
I've tried a few different ways and just can't grasp how the linq is supposed to go to get the results I want. I can get an incident value, or network value, but not both.
I have the proper association set up in the dbml so both of these work to get the single value:
var b = from i in edcwdv.WOCUSTFIELDs join p in edcwdv.WORKORDERs on i.WORKORDERID equalsp.WORKORDERID where i.CUSTFIELDNAME.Contains("INCIDENT") select new { i.CUSTFIELDNAME, i.CUSTFIELDVALUE, p.WORKORDERID };
var incident = from wo in edcwdv.WORKORDERs orderby wo.WORKORDERID where wo.WOCUSTFIELDs.CUSTFIELDNAME.Contains("INCIDENT") select new { wo.WORKORDERID, wo.WOCUSTFIELDs.CUSTFIELDVALUE}; So essentially i want to pull the value for each of the fields, INCIDENT and NETWORK
View 2 Replies
Similar Messages:
Feb 23, 2011
how to insert records in multiple table using with foreign key with linq to sql?
View 2 Replies
Jan 21, 2011
Is it possible to create a table class that can be used for multiple tables? For example, if I have some class:
[Code]....
In LINQ to SQL, this maps to a table with a name based on the class name, DBClass. However, suppose I want to use that class for multiple tables, and it could be an arbitrary number of tables. Is this possible
View 3 Replies
May 14, 2010
i am new to this linq concept,
i have used the following code to delete multiple records in my table,
but when i hit the button insteading deleting multiple records only one record is getting deleted
below is the code
protected void Button1_Click(object sender, EventArgs e)
View 10 Replies
Jul 2, 2010
The gist of the problem is that we have an alumni table (one record per person) and also a couple of other tables (one to many) that have degree info and interest info. In a search screen in our app you can search for criteria that spans all three tables (there are actually more fields and tables than shown in the example below but I am trying to keep it simple).
The code below works (properly returns people without degrees for example) but still feels a little clunky or over-engineered to me. Are there easier ways to do this? NOTE: I have been through quite a few iterations/approaches to making the correct data be returned.
[code]....
View 1 Replies
Jun 29, 2010
how can i select a record from A table and insert into B table using linq?
View 2 Replies
Jan 28, 2011
I have some problems trying to query my database. The problem is that I'm not sure how to multiple join tables in my database.
tables to make it easier:
[code]....
What I'm supposed to do is to find all the teachers (predavac) who were teachers on the specific activity (aktivnost) and who had specific attendee (polaznik). The problem is I'm not sure how to do multiple joins on this one.
View 1 Replies
Mar 15, 2011
I have to find the best way to do this using LINQ. I need to summarize an amount in a iTransaction table by
Account (e.g. 12345) and add that amount to an same Account ( e.g12345) if it exists in a iAccount table . Here is the code which syntax checks ok and tested ok up to the .submitChanges statement (i.e. I stopped and didn't allow the submit.
Following is the LINQ code. (1) Is that a good way to do this. OR should I try the INTERCEPT.
(2) How is the best way to insert a new record/row in the iAccounts table if it DOES NOT exist in the iAccount Table.
[Code]....
View 2 Replies
Oct 5, 2010
i have multiple tables .
I have created one stored procedure where I am selecting the table values.
like
[code]....
I am using LINQ to retrieve the Data. So Using Linq I am calling the stored procedure.
So I ll get the table values in the C# Code the table values.
so in my UI i have 4 gridviews.
I want split the output values into four source and bind it to the grid.
View 1 Replies
Feb 21, 2011
I've scenerio where i've two dropdownlist box (one dependent on other, displays handset brand name and on selection displays the respective model name), two combolistbox which is bounded to their respective datasource(Displays the fault and accessories).
Now i've to update the three tables booking(Handsetid, Brand,model), accessories(handsetId,AcesoriesID) and fault(handsetID,faultID). Ive to update multiple rows in Accessories and fault.
These controls are present in datagridview EditTemplate
View 4 Replies
Feb 27, 2011
I have a question about linq delete.
I have 2 table in database and they are joined.
First Table: UserID, UserName, UserSurname, UserPhone, CompanyId
Second Table: CompanyId, CompanyName
First Table I have many recods with related second table.
I want to delete one company in second record, But firtly I have to delete users (more than 1)
How can I delete it with using linq?
View 2 Replies
Feb 1, 2011
how to update a value in a table using multiple table in sql?
View 2 Replies
Dec 25, 2010
i want add a record to my table(News) in the database School.
so i create a class for news table look like this:
public class News
{
private int _newsid;
private string _datetoshow;
private string _title;
private string _description;
private string _writtenby;
public int NewsID
{
get { return this._newsid; }
set { this._newsid = value; }
}
public string DateToShow.......
pop up is:
'system.Data.Linq.Table <New>' does not contain a definition for add and no extension method 'Add' accepting a first argument of type 'System.Data.linq.Table<New>' could be found (are you missing directive or an assembly reference?)
View 3 Replies
Oct 10, 2010
i use Default membership provider for my membership
i add a profile table for some more information from user and it related with UserId with aspnet_Users
to get data from my database i use Entity Data Model
now i want to write a Linq to get data from all 3 tables
View 1 Replies
Feb 2, 2010
In my application i want to compare data of two users from database table using linq.
lets say i have ten columns in UserMaster table.
Now based on the comparision i want to display result.
Like is 10 out of 10 columns matches for those two users result will be 100,if 9 columns matches then result will be 90 and if 0 matches thn result will be 0.
i dont want to write if else for somany time.
I am new to linq.
View 4 Replies
Jul 18, 2010
Using Visual Studio I've created a DBML file, and added a table to it from a local database. This created a data context called UserDataContext. In my ASPX page I can create an instance of the data context using:
UserDataContext db1 = new UserDataContext();
However when I try to query against the table I get to:
var query = from o in db1.
and from there I can't see the table.... the dbml shows the table has public access.
View 6 Replies
Aug 10, 2010
how can i do a join in this query to another table
dynamic list = _db.Users.Where(m => m.vcr_UserName != "superadmin" ).OrderByDescending(m => m.int_UserId).ToPagedList(Cpage, defaultPageSize);
i must have a topagedList there
View 1 Replies
Jun 13, 2010
The objective is to send automated emails to which of whom come from the results of my LINQ to SQL script. As I am not sure on 'automated' stuff I was going to approach this in the aspect of having a field in the table that the results are taken from change after the emails have been sent i.e. obj.EmailSent = true; - So that everytime the admin homepage is loaded it isnt sending it out again (eliminating duplication).
From that I would have to create a method to detect a new year and upon that reset all entries of the EmailSent field in the DB table to 'false', but for now its just the initial problem thats causing confusion.
I was going to opt for a 'foreach' solution so that all the recipients, individually, get their emails and not all together. Its the 'foreach' I'm not sure on as well as setting all the results collected to the new value of 'EmailSent' to 'true'.
Here is my attempt:
C#:
[code]....
View 9 Replies
Aug 17, 2010
I have a partitioned db where several tables have the exact same structure. I'm able to query the tables using linq, but only by quering the individual tables 1 at a time and by using the explicit table name. For example at the moment, I have 8 tables so I have something similar to the following:
[Code]....
Is there any way, that based on a certain value (stringValue), I could determine which table to query and then code the linq query just once?
View 2 Replies
Aug 12, 2010
I have a couple tables that are kind of unrelated - id like to search through both of them and create a type that i can sift through later
something like this doesnt work
[Code]....
I basically want to create a list of "AnimalSearchResults" that contains all dogs and all cats that have that name Whats the best way to do something like this?
View 6 Replies
Mar 18, 2011
When I am updating a record with linq to sql my DeleteLesson() method is getting called multiple times.My controller looks like this :
public ActionResult Delete(int id)
{
deleteLesson(id);[code]....
EDIT.also if I use confirm = "Do you want to delete" in ajax options I will have to click okay three times.
View 1 Replies
Jul 4, 2010
I'm creating a repository and service layer in my app, and my repo has a very simple function
Public Function GetRegions() As IQueryable(Of Region) Implements IRegionRepository.GetRegions
Dim region = (From r In dc.Regions
Select r)
Return region.AsQueryable
End Function
Now in my Service layer I've got a function like this
Public Function GetRegionById(ByVal id As Integer) As Region Implements IRegionService.GetRegionById
Return _RegionRepository.GetRegions().Where(Function(r) r.ID = id).FirstOrDefault
End Function
But i can't figure out how to add And r.isActive = True
how to have multiple operators in this query?
View 3 Replies
Aug 8, 2010
Using Linq to Sql how do i group the following 2 tables.
Orders Table:
CustomerID | Name |Date
1 | order1 | 2010-01-01
2 | order2 | 2010-01-01
2 | order3 | 2010-04-01
Calls Table:
CustomerID | Name |Date
1 | call1 | 2010-01-01
3 | call2 | 2010-06-01
2 | call3 | 2010-05-01
I want to group the two tables by date , Result:
Date | Orders | Calls
2010-01-01 | 2 | 1
2010-04-01 | 1 | 0
2010-05-01 | 0 | 1
2010-06-01 | 0 | 1
i know how to group a single table ,from o in Orders group o by o.Date.Date into og select new {Date = og.Key,Orders= og.Count()};
View 2 Replies
Aug 17, 2010
How can I declare multiple groups in LINQ? I get this error "Range variable 'Group' is already declared." Error found in bold and underlined text below.
Dim SportsWear = From c in dbContext.SportsTable Group Join grp_Attire In dbContext.AttireTable On grp_Attire.AttireId Equals c.AttireId Into Group From sportsAttire In Group.DefaultIfEmpty() Group Join grp_SportType In dbContext.SportType On grp_SportType.TypeId Equals c.TypeId Into Group From sportsType In Group.DefaultIfEmpty() Select New With { _ .Attire = sportsAttire.AttireName,.Type = sportsType.TypeName}
View 1 Replies
Sep 29, 2010
I am trying to delete three related objects on one submit. Delete fails on one of the child objects, because of foreign key contraint with another table, It deletes one (the parent) but not the two child objects. All in one SubmitChanges(). I even used the TransactionScope, still same thing. So here is the scenario:
I have an object called Page which has a collection of objects called Webinars. There is another object Called Product which is one to one with Webinar.
[Code]....
View 5 Replies