This is a migrated thread and some comments may be shown as answers.

Case statement

1 Answer 83 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mehul Patni
Top achievements
Rank 1
Mehul Patni asked on 04 Jul 2009, 04:31 PM
Hi All,

      How can I use case statement along with select. here is my problem.

   var query = from contracts in scope.Extent<VARMSContract>()
                        join employee in scope.Extent<VARMSEmployee>() on contracts.EmployeeID equals (employee.EmployeeID)
                        select new
                        {
                            ContractID = contracts.ContractID,
                            ContractTitle = contracts.ContractTitle,
                            ContractDesc = contracts.ContractDesc,
                            ContractStartDate = contracts.ContractStartDate,
                            Owner = employee.EmployeeFirstName + " " + employee.EmployeeLastName,
                            ContractTypeName = contracts.VARMSContractType.ContractTypeName,
                            CounterParty =
                            contracts.VARMSContractType.ContractTypeID == 1 ? Here I want a customer name from VARMSCustomer class :
                            contracts.VARMSContractType.ContractTypeID == 2 ? Here I want a manufacturer name from VARMSManufacturer class :
                            "N/A"
                        };

How can I do that?

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 06 Jul 2009, 01:36 PM
Hi Mehul Patni,

The case statement should work exactly as you have written it. The problem here is that Telerik OpenAccess ORM does not support joins in Linq queries yet. This functionality is scheduled to be implemented for our 2009 Q3 release later this year. In the meantime you can use a reference from the VARMSContract class to the VARMSEmployee class. If you are using the Reverse mapping approach but you do not have this reference, you can create it from the Reverse mapping wizard. Open the wizard and select the VARMSContract.EmployeeID from the treeview. Then click the "Create Ref." button, choose the reference type (VARMSEmployee) and select the EmployeeID column from the combobox in the grid below. Regenerate the class and the reference should be there. Now you will be able to reach the related employee object from VARMSContract.TheNewReferenceName and use it in the Linq query.

All the best,
Alexander
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
LINQ (LINQ specific questions)
Asked by
Mehul Patni
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or