Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6770595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:19:51+00:00 2026-05-26T15:19:51+00:00

I am trying to do the following: http://msdn.microsoft.com/en-us/library/dd456857.aspx I created the function in the

  • 0

I am trying to do the following:
http://msdn.microsoft.com/en-us/library/dd456857.aspx

I created the function in the edmx file here just before the schema element:

<Function Name="YearsSince" ReturnType="Edm.Int32">
  <Parameter Name="date" Type="Edm.DateTime" />
  <DefiningExpression>
    Year(CurrentDateTime()) - Year(AppliedDate)
  </DefiningExpression>
</Function>
      </Schema>

Now, I want to be able to use that in a query.
I created the following code in the ApplicantPosition partial class

[EdmFunction("HRModel", "YearsSince")]
        public static int YearsSince(DateTime date)
        {
            throw new NotSupportedException("Direct calls are not supported.");
        }

And I am trying to do the following query

public class Class1
{

    public void question()
    {
        using (HREntities context = new HREntities())
        {
            // Retrieve instructors hired more than 10 years ago.
            var applicantPositions = from p in context.ApplicantPositions
                              where YearsSince((DateTime)p.AppliedDate) > 10
                              select p;

            foreach (var applicantPosition in applicantPositions)
            {
                Console.WriteLine(applicantPosition.);
            }
        }

    }
}

The YearsSince is not recognized, the MSDN tutorial does not show exactly where I need to put the functio, so that might be my problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:19:52+00:00Added an answer on May 26, 2026 at 3:19 pm

    Your static YearsSince function must be defined in some class so if it is not Class1 you must use full identification with class name to call it. Check also this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying set up an execution account following the steps here: http://msdn.microsoft.com/en-us/library/ms156302.aspx I follow
I am trying to follow the steps on the following site http://msdn.microsoft.com/en-us/library/ms181089(VS.80).aspx But I
I am trying to understand the 'SocketAsyncEventArgs' class in C#. http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.aspx I am following
I am trying to enable SQL Debugging following this link http://msdn.microsoft.com/en-us/library/ms165038%28VS.80%29.aspx but i can't
I am trying to follow this example: http://msdn.microsoft.com/en-us/library/aa179614%28SQL.80%29.aspx# It says to add the following
I have created a WCF Client with the SVCUTIL.exe following these instructions : http://msdn.microsoft.com/en-us/library/ms733133.aspx
I'm trying to use the WMI example from msdn: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384724%28v=vs.85%29.aspx I've copied the last
This is killing me. I've read these: http://msdn.microsoft.com/en-us/library/athddy89(v=VS.80).aspx http://msdn.microsoft.com/en-us/library/2baksw0z(v=VS.80).aspx But I don't see how
Using the code available on the link: http://msdn.microsoft.com/en-us/library/aa969393.aspx HRESULT CreateLink(LPCWSTR lpszPathObj1, LPCSTR lpszPathLink, LPCWSTR
According to MSDN I can have an OnClick for a LinkButton --> http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.onclick(v=VS.90).aspx However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.