.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> LINQ >> Post New QuestionBookmark and Share Subscribe to Forum

linq Query

Posted By: Sethuraman     Posted Date: February 08, 2011    Points:2   Category :LINQ
Hi All

I have written a linq query which has combination of two table using the condition i have selected . now my doubt is in the query i have got condition checking correct but i need to take record from my second table ans show it but i can't can any on tell.

var movies = (from m in emp.Emps join n in emp.emp_desig on m.id equals n.id where m.id==2 select m);

return View(movies);

where here emps and emp_desig is two table fields are

emps

id , name, age

emp_name

id , designation , description

using query i can retrieve only emps table record now i need to take designation for selected record .



Regards
Sethu
Make your own way if don't find any...
Success never achieve without failure.

Responses
Author: Blessy Baby             
Posted Date: February 09, 2011     Points: 5   

Hi,

I am not clear your issue. do you need to take the record with specified fields.

try this
var movies = (from m in emp.Emps join n in emp.emp_desig on m.id equals n.id where m.id==2
select new (m.Name,n.designation);



Blessy Baby
Project Lead
Digitalmesh Softech India (p) Limited
Cochin,Kerala
Author: Sethuraman             
Posted Date: February 15, 2011     Points: 5   

Hi

Thanks for you query , i have got result based on your query .

Now my problem is when i return .

return View(movies);

It show conversion error.

I have created a class with get set initialization and using this method i have created the class

public class Employee_models
{

private int _Id;
private string _Name;
private int _Age;
private string _designation;

public int Id
{
set
{
_Id = value;
}
get
{
return _Id;
}
}
public string Name
{
set
{
_Name = value;
}
get
{
return _Name;
}
}
public Int32 Age
{
set
{
_Age = value;
}
get
{
return _Age;
}
}

public string designation
{
set
{
_designation = value;
}
get
{
return _designation;
}
}

}


This is the modal class created . view also created based on this class . for this i face an conversion error.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend