How to perform innner Join on Five Tables using Linq [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
gameScheduling db = new gameScheduling();
var query = from c in db.tblgroupDetail
join g in db.groups on c.GroupId equals g.GroupId
join t in db.Tournaments on c.TournamentId equals t.tournamentId
and so on......
select new {c.Name etc etc}
I have an error on join plz some useful suggestions.

Are the types of your expression variables the same?
E.g.: are c.GroupId and g.GroupId both int or is one of them of type byte?
The types of the variables in your expressions must be of the same type if you want to compare them with each other.

I think you have to use .Value with the field name in the select clause....

I did one similar scenario it may help you please check below link
Join two data table and return new table

Related

I want compare two string and want to get possible matches [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
sb.Qualilfication_Master.First().Qual_List contain string values like "B.C.A,M.C.A,B.B.A"
and txtQualification.text contain string like "B.C.A, M.Com"
I want match above two thing
var sendnoti = (from p in db.Reg_JobSeeker_Masters where p.Qualification_Masters.First().Qual_List.Contains(txtQualification.Text)select p).ToList();
If I'm reading this right - and you want to find the strings that are common to two lists - then you can just use the intersect method.
I am just assuming txtQualification.Text is a List<string> so in that case you could just right it like this -
var sendnoti = (from p in db.Reg_JobSeeker_Masters where p.Qualification_Masters.First().Qual_List.Any(ql => txtQualification.Text.Contains(ql))select p).ToList();

Composite Key WITH Operator IN and SubQuery [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have this inner join and I'm using LINQ to make my queries, how can I write this query with LINQ, I was seeking it on internet but I cant find something like.
INNER JOIN e210mvp mvp
ON mvp.codemp IN (1 , 2)
AND mvp.codlot = dls.codlot
AND mvp.datmov = (SELECT MIN(min.datmov)
FROM e210mvp min
WHERE min.codemp = 1
AND min.codlot = mvp.codlot)
Thank you!
Leave the equality tests in the join and move the non-equality tests to where. Note that the equality tests must involve the left hand side (or an expression involving it) equals the right hand side (or an expression involving it). Since you have mvp on both sides of the sub-select test, you can't leave it in the join operation.
join mvp in e210mvp on dls.codlot equals mvp.codlot
where new[] { 1, 2}.Contains(mvp.codemp) &&
mvp.datmov == e210mvp.Where(min => min.codemp == 1 && min.codlot == mvp.codlot).Min(min => min.datmov)

Can't compare int and IQueryable<int> and need all rows, not FirstOrDefault() [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I am getting a type error. Cannot compare int and IQueryable
I have looked for help on this, but have only seen info on .FirstOrDefault() and single and other methods to return on result row. The issue I am having is that I want all rows where the product p matches the subcategory. Normally it doesnt seem to be an issue when grabbing multiple rows, but while it seems to be common, I cant figure it out
var subcategoryId = someNumber;
productDetails =
from p in db.Products
where p.SubCategoryId == subCategoryId
select p;
If subCategoryId is not a single value (seems like that) then try to use Contains
productDetails = from p in db.Products
where subCategoryId.Contains(p.SubCategoryId)
select p;

Database field Enum to C# List [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
In my database I have a Enum field. I want to put those Enum attributes in a List in C#.
I searched but I couldn't find the answer. Is this possible?
I use a MySqlDatabase. If I want to get the rows from the database I use:
using (var uow = new UnitOfWorkScope<TrackerEntities>(UnitOfWorkScopePurpose.Reading))
In my application I use the Entity Framework
if you loading data in a data reader, however this is sql-server way. But point here is to convert string into enum
var list = new List<YourEnumType>();
var field= reader["DBFieldName"] != DBNull.Value ? reader["DBFieldName"].ToString()
: "";
var myField=(YourEnumType) Enum.Parse(typeof(YourEnumType ), field);
list.Add(myField);
Also have a look at The ENUM Type
You'll need to make a query against the schema table to list the enum values.
SELECT COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = #TABLE_NAME AND
COLUMN_NAME = #COLUMN_NAME

Linq join with conversion [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am doing a kind of Join in my MVC application by using LINQ as,
var temp= (from enumeration in db.Enumerations
join cust in db.Customers on Convert.ToInt32(enumeration.Value) equals cust.lkpStatus
where (cust.ID==data.ID &&
enumeration.EnumerationTypeID.Contains("Customer.lkpStatus") )
select enumeration).FirstOrDefault();
In this I have got a Problem on Join is that "enumeration.Value" is a string value and " cust.lkpStatus" is an int.
So how can be the query to do joining by using the LINQ. Please suggest some LINQ query in this scenario.
try with SqlFunctions.StringConvert
join cust in db.Customers on
enumeration.Value equals SqlFunctions.StringConvert((decimal) cust.lkpStatus).Trim()

Categories