This project is read-only.

Is an "Id" Column Required

May 18, 2016 at 1:57 PM
Great project. Thank you for making it open-source.

I am wondering why I am getting this error when I run it against this table:

DynamicMVC.Data.ParseException was unhandled by user code
  Message=No property or field 'Id' exists in type 'Note'
       at DynamicMVC.Data.ExpressionParser.ParseMemberAccess(Type type, Expression instance) in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 1290
       at DynamicMVC.Data.ExpressionParser.ParseIdentifier() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 1098
       at DynamicMVC.Data.ExpressionParser.ParsePrimaryStart() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 966
       at DynamicMVC.Data.ExpressionParser.ParsePrimary() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 941
       at DynamicMVC.Data.ExpressionParser.ParseUnary() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 936
       at DynamicMVC.Data.ExpressionParser.ParseMultiplicative() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 883
       at DynamicMVC.Data.ExpressionParser.ParseAdditive() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 853
       at DynamicMVC.Data.ExpressionParser.ParseComparison() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 770
       at DynamicMVC.Data.ExpressionParser.ParseLogicalAnd() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 755
       at DynamicMVC.Data.ExpressionParser.ParseLogicalOr() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 740
       at DynamicMVC.Data.ExpressionParser.ParseExpression() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 724
       at DynamicMVC.Data.ExpressionParser.ParseOrdering() in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 700
       at DynamicMVC.Data.DynamicQueryable.OrderBy(IQueryable source, String ordering, Object[] values) in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicLinq.cs:line 57
       at DynamicMVC.Data.DynamicRepository.GetItems(Type type, IEnumerable`1 filters, Int32 page, Int32 pageSize, String orderBy, String[] includes) in c:\CodePlex\DynamicMVC\DynamicMVC\DynamicMVC\Data\DynamicRepository.cs:line 78
       at DynamicMVC.UI.DynamicControllerManager._Index(Func`2 filter) in c:\users\c-mpomar\documents\visual studio 2015\Projects\DynamicNorthwind\DynamicNorthwind\DynamicMVC\DynamicControllerManager.cs:line 68
       at DynamicMVC.UI.Controllers.DynamicController._Index() in c:\users\c-mpomar\documents\visual studio 2015\Projects\DynamicNorthwind\DynamicNorthwind\Controllers\DynamicController.cs:line 43
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
CREATE TABLE [dbo].[Notes](
    [NoteID] [bigint] IDENTITY(1,1) NOT NULL,
    [EntityType] [nvarchar](100) NOT NULL,
    [EntityID] [bigint] NOT NULL,
    [Text] [nvarchar](max) NOT NULL,
    [InsertUserId] [int] NOT NULL,
    [InsertDate] [datetime] NOT NULL,
    [NoteID] ASC
It does this for nearly all my tables. My guess is it requires the table to have a column called "Id" to work.

On a side note, I'd love to see this project live on. Doesn't look like there's been any updates lately. Are there any plans for improvements or new features?
May 19, 2016 at 1:57 AM
I believe Guids are supported. I don't remember if the current active version requires a primary key named "Id" or not. I remember testing guids. Worst case you can name the property Id and leave the column name whatever you want. I believe there is a column attribute in entity framework that helps with this. I wouldn't populate the guid. I would recommend doing it in the constructor. If you are retrieving an existing model from the db with an existing guid, this one will override what you do in the constructor, so you should be covered in all scenarios. I know in version 3 you can set the key name on the dynamic entity attribute.

I am working on Dynamic MVC 3.0. I will be releasing a preview this month. I will send you an email when this is completed. I am hoping to get more community contributions in the next version. I will be moving to github since this seems to be where all the cool kids are.

Thank you for your interest and support.
May 19, 2016 at 5:17 PM
Thanks for the tip. I'll give that a shot. I think I did see somewhere in the source where it is expecting to have Id, Name, or a Description field by default - I believe when the initial grid loads and it sets a default sort order. Perhaps a simple solution is to not set a default sort order, or make that configurable using attributes.

Looking forward to seeing the 3.0 version.

Thanks again for contributing this project. :)