Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface with different interface collection as property #21

Open
buddhamanglerdefi opened this issue Dec 2, 2016 · 0 comments
Open

Comments

@buddhamanglerdefi
Copy link

buddhamanglerdefi commented Dec 2, 2016

I cannot figure out how why ActLike is having issues in this particular case. I am testing a controller action that returns a JsonResult and I am attempting to do actionResult.Data.ActLike(typeof(IRow)). the returned object for that call has the outer properties populated just fine, but is having big problems with the 'rows' property. When I try to enumerate it, it says the object does not have GetEnumerator method. What is the proper way to do this? I have tried other iterations where the property is IRow[] which also does not work. Also I am unsure whether my call to ActLike needs the typeof(IRow) parameter,

            var zipPreferenceData = credentials.Select(s => new
            {
                id = s.Id,
                cell = new[] { "1", "2", "3", "4", "5" , "6" }
            });

            var jqGridData = new { page = 1, total = 1, records = credentials.Count, rows = zipPreferenceData };
            return new JsonResult { Data = jqGridData, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    public interface IJqGridData
    {
        int page { get; set; }
        int total { get; set; }
        int records { get; set; }
        IList<IRow> rows { get; set; }
    }

    public interface IRow
    {
        long id { get; set; }
        string[] cell { get; set; }   
    }

var data = actionResult.Data.ActLike<IJqGridData>(typeof(IRow));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant