Case statement

2 posts, 0 answers
  1. Mehul Patni
    Mehul Patni avatar
    2 posts
    Member since:
    Jul 2009

    Posted 04 Jul 2009 Link to this post

    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?

  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 06 Jul 2009 Link to this post

    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.
  3. DevCraft banner
Back to Top