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 6073863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:19:05+00:00 2026-05-23T10:19:05+00:00

I am migrating some code and have nicely formatted Look-up Tables but they have

  • 0

I am migrating some code and have nicely formatted Look-up Tables but they have to be converted into archaic structures for use because of backward compatibility.

I have a GetLookupTable() method which goes and gets a list of SelectItemList, all off my models and lookup calls are code generated but I need to manually alter some of the return SelectItem’s so I have implemented a Visitor Pattern that the developer can implement if they wish.

The visitor is done as a Partial Method and if developer wants to implement they can, but I’m getting an error as shown below

Error 132 Cannot create delegate from method ‘InfoChoice.Web.Admin.ViewModels.Product.ProductCreditCardViewModel.LookupTableViewModel.CardTypeVisit(System.Web.Mvc.SelectListItem)’ because it is a partial method without an implementing declaration

Here is the calling code using Razor

<div class='row'>
    <label>Card Type</label>
    @Html.CheckBoxListFor(model => model.CardType, @Model.LookupTable.CardType)
    David Says: @Model.CardType
</div>

Here is a stripped down Model

// Generated model
public partial class ProductCreditCardViewModel
{
    [Required]
    [DisplayName("Account - Card Type")]
    [DefaultValue("")]
    public string CardType { get; set; }


    // ***************************************************************************************************
    // Lookup Table calls for this model (Generated)
    // ***************************************************************************************************
    public partial class LookupTableViewModel : BaseLookupTableViewModel
    {
        partial void CardTypeVisit(SelectListItem item);

        public SelectList CardType
        {
            get
            {
                return GetLookupItems("ProductCreditCardCardType", CardTypeVisit);
            }
        }
    }

}

public partial class ProductCreditCardViewModel
{
    // Custom Implementation Goes Here
    public partial class LookupTableViewModel : BaseLookupTableViewModel
    {
        //partial void CardTypeVisit(SelectListItem item)
        //{
        //    item.Value = "|" + item.Value + "|";
        //}
    }
}

Base LookupTable view model that will return Select Item List data

public class BaseLookupTableViewModel
{
    public SelectList GetLookupItems(string lookupName)
    {
        return GetLookupItems(lookupName, "Name", "Text", null, null);
    }
    public SelectList GetLookupItems(string lookupName, Action<SelectListItem> itemVisitor)
    {
        return GetLookupItems(lookupName, "Name", "Text", null, itemVisitor);
    }
    public SelectList GetLookupItems(string lookupName, string dataValueField, string dataTextField, object selectedValue, Action<SelectListItem> itemVisitor)
    {
        // Go get some data from DataStore
        var list = App.Data.Lookup.GetLookupList(lookupName);

        // Convert to IEnumerable<SelectItemList>
        var result = new SelectList(list, dataValueField, dataTextField, selectedValue);

        // If developer would like to alter that list before it is returned, then developer should implement an item visitor
        if (itemVisitor != null)
        {
            foreach (var item in result)
            {
                itemVisitor(item);
            }
        }

        return result;
    }

    public void SampleVisitor(SelectListItem item)
    {
        item.Value = "Modified: " + item.Value;
    }
}
  • 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-23T10:19:06+00:00Added an answer on May 23, 2026 at 10:19 am

    The error is correct; partial methods do not exist if not implemented, so you can’t bind a delegate to them in quite that way. Your best option here is either to call it manually based perhaps on a switch (or similar), or if you really need a delegate, look for the method with reflection (remembering to specify non-public binding-flags) and use Delegate.CreateDelegate if the method turns out to exist. Or a lazy option:

    private void OnCardTypeVisit(SelectListItem item) { CardTypeVisit(item); }
    partial void CardTypeVisit(SelectListItem item);
    

    now bind your delegate to OnCardTypeVisit instead of CardTypeVisit.

    In terms of delegates, this could also be as simple as changing it to an indirect delegate, which is very similar to the On* approach:

    return GetLookupItems("ProductCreditCardCardType", x => CardTypeVisit(x));
    

    (however, if that is an expression rather than a delegate I would expect failure)

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

Sidebar

Related Questions

I'm migrating some code from the ASPX view engine to Razor and I've run
I have a Delphi app that we're migrating to C++. One thing I often
I am migrating a SOAP web service to JDK1.5. I have took advantage of
I have Core Data application and I have been migrating (upgrading) the core data
I have added username to a devise authentication setup, and for some reason, it's
Our development team is currently looking into migrating our search system to Apache Solr,
We have an extensive existing codebase and we've added load-balanced servers with a single
I'm currently migrating a working app from CakePHP 1.2 to 1.3. Most things seem
I am using Ruby on Rails 3.0.7 and I am migrating from Prototype to
I'm investigating on how validates_presence_of actually works. Suppose I have two models class Project

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.