CSLA .NET Contrib News Feed 
Monday, March 02, 2015  |  From CSLA .NET Contrib

Dears,


last week i ordered the "Using CSLA Series" eBook, but i received the payment notification received successfully. but i did received the Username and Password to Login and download the eBook. this is since (25 Feb, 2015). any help please ??

Saturday, February 28, 2015  |  From CSLA .NET Contrib

10 years ago I architected a solution where we used CSLA to develop a custom ERP system using CSLA for .Net\WinForms. Now, I am looking to start a similar project and was wondering if this is still a good bet. We need a solid, reliable and Scalable distributed windows framework (some functionality might be extended to web and mobile in the future). I am still interested in a reliable business object framework and CSLA is a familiar entity. Is it still a good bet? Also, CodeSmith seems to be lagging with regards to supporting the latest CSLA versions (is there an up to date template generator out there?). I would appreciate your thoughts and guidance. Thank you in advance.

Friday, February 27, 2015  |  From CSLA .NET Contrib

I am trying to implement object factory support with a read only object and would like to know the best way to populate it.

Friday, February 27, 2015  |  From CSLA .NET Contrib

So I have my MVC project wired up using the latest ASP.Net identity and registration and login works fine. Now to wire into the Csla principal and am wondering how to do this.


How much of the ASP.Net identity bits and pieces can I realistically move into the DalEF project (I'm following the ProjectTracker solution here)?


Anyone tried to implement the SignInManager, UserManager, RoleManager in the Dal like the example simple web membership methods;


Membership.ValidateUser(username, password)


and


var user = Membership.GetUser(username);
var result = new UserDto { Username = username };
result.Roles = Roles.GetRolesForUser(result.Username);
return result;


Thanks.


Richard.


 

Thursday, February 26, 2015  |  From CSLA .NET Contrib

Hello everyone. I have inherited a project that is using CSLA version 1.51.2163.27113. There is a method in the NameValueList component of this assembly named SimpleTableFetch with a signature of CSLA.NameValueList.SimpleTableFetch(String, String, String(), ByRef System.Data.DataTable).


I don't see this method in any of the 1.5 versions of source code on the website. This leads me to guess that the method was added by a previous programmer; but there are no signs of CSLA source code anywhere on my end. I only have DLLs.


Is it possible that this method was part of CSLA at some point; and, if so, where might one find the source code?


Thanks in advance.

Monday, February 23, 2015  |  From CSLA .NET Contrib

Can anyone point me to an example of calling an asynchronous method on a business object from a controller in ASP.Net MVC 5?   Or just show me what the call would be and how the business object method is done.


Currently confused looking at the examples in ProjectTracker, and wondering if GetProjectList<EventHandler<DataPortalResult<ProjectList>> callback) is what I need.


Thanks,
Richard. 


 

Saturday, February 21, 2015  |  From CSLA .NET Contrib

I know MVVM has been around for a number of years.


On October 03, 2011 Rocky wrote on Why MVVM?:



Does MVVM mean you can completely avoid changing code when the XAML changes? No. But it is a whole lot closer than any other technique I’ve seen in my 24+ year career.



 


On May 07, 2012 Rocky wrote on Using the MVVM pattern requires a framework:



In the meantime, Caliburn Micro appears to be the best MVVM framework out there – certainly the most widely used.



 


I guess both the statements are still true:


  • doing MVVM is a must
  • Caliburn.Micro is the best MVVM framework around

It happens some people still develop in Windows Forms. It also happens Visual WebGUI is a Windows Forms look alike, that instead of making desktop applications, makes web applications.


The point is about MVVM and the lack of decent port of a MVVM framework - any framework - to these programming environments. There are a number of partial solutions but nowhere near the real thing.


Interesting enough, people spent more time arguing why MVVM can't be done on Windows Forms and why Caliburn.Micro can't be ported to Windows.Forms than actually trying to do it.


It turns out that since Mar 14, 2012, there was an almost complete port of Caliburn.Micro to Windows Forms hidden among the +100 forks of Caliburn.Micro. Dan Durland is the author of this port.


The MVVM FX Project took it as a starting point. Some major Caliburn.Micro features were missing but now they are working as they should. We can say the port is in beta stage.


Before a formal release announcement is made, a few more samples must be made. A Csla Adapter (ViewModelBase) is planned as well as a Csla sample.


Since there are enough samples to understand how to use the most basic features, you are invited to start using it right now.

Friday, February 13, 2015  |  From CSLA .NET Contrib

I am using CSLA.NET and I have problem with executing long running commands on server from client.Underlying WCF connection is terminated after a minute a client doesn't get a result.


 My idea was to use second command for periodically observing progress of first command (running in new thread) as a benefit I get option get status information and result once is finnished. But unfortunately I can't get it working without getting it too much complex. Any ideas or anything in CSLA which will help me with this?


 

Wednesday, February 11, 2015  |  From CSLA .NET Contrib

I'm looking through the code for Csla, and it seems the check for things like GetObject are done client side before the call is made to the data portal, which is good in that a remote call won't be made if the user lacks permission.


However it doesn't look like the check is repeated on the server side. I can certainly call BusinessRules.HasPermission at the start of each DataPortal_XYZ method, but it feels like the framework should handle this. 


Is if my current understanding is correct and I need to do the check myself in the DataPortal_XYZ methods?


If that is correct, could we get a feature to do this automatically?


This is Csla 4.5.601.

Monday, February 09, 2015  |  From CSLA .NET Contrib

Version 4.5.700 is now available via NuGet and GitHub.


This version primarily adds support for the Xamarin Unified API and new iOS project types, but also includes a number of bug fixes and minor enhancements.


For full details: https://github.com/MarimerLLC/csla/releases/tag/4.5.700

Monday, February 09, 2015  |  From CSLA .NET Contrib

I am trying to write a reusable business rule that would take an editable collection property and an int value and add a broken rule to my root if the count of the collection is greater than the value.


So far, I have written the following business rule but I was hoping you can help me optimize it. Somehow it doesn't feel pretty. I would rather specify the type of the collection which is specified when the property is registered than that of the item.  All I really need to get out of all this is the count of the collection (regardless of the item type).


I am using CSLA 4.3.12


Thanks


 


public class CollectionMaxCountRule<C> : PropertyRule


{


private int MaxCount { get; set; }


 


public CollectionMaxCountRule(IPropertyInfo primaryProperty, int maxCount): base(primaryProperty)


      {


MaxCount = maxCount;


PrimaryProperty = primaryProperty;


InputProperties = new List<IPropertyInfo>() { primaryProperty };


AffectedProperties.Add(primaryProperty);


 


}


 


protected override void Execute(RuleContext context)


{


ICollection<C> _list = (ICollection<C>)context.InputPropertyValues[PrimaryProperty];


 


 


if (_list.Count > MaxCount)


context.AddErrorResult(PrimaryProperty, string.Format("{0} {1}", ResourceFiles.LibraryResources.CollectionMaxCountRule_Error_MaxCount, MaxCount.ToString()));


}


}



 


 It is added using the following:


 





BusinessRules.AddRule(



 



new CollectionMaxCountRule<CostEstimate>(CostEstimateCollectionProperty, int.Parse(ConfigurationManager.AppSettings["MaxCostEstimateCount"])));





 


Wednesday, February 04, 2015  |  From CSLA .NET Contrib

I have the following business classes


 


        public class EditableRoot:Csla.BusinessBase<EditableRoot>
    {
        public string Name { get; private set; }
        public int Id { get; private set; }

        public static EditableRoot New() {
            return DataPortal.Create<EditableRoot>();
        }

        public static readonly PropertyInfo<EditableChildList> ChildListProperty = RegisterProperty<EditableChildList>(c => c.ChildList, RelationshipTypes.Child);
        public EditableChildList ChildList
        {
            get { return GetProperty(ChildListProperty); }
            private set { SetProperty(ChildListProperty, value); }
        }
        protected override void DataPortal_Create()
        {
            ChildList = EditableChildList.New();
        }

    }
    public class EditableChildList : Csla.BusinessListBase<EditableChildList,EditableChild>
    {
        public static EditableChildList New() { return DataPortal.CreateChild<EditableChildList>(); }
    }
    public class EditableChild : Csla.BusinessBase<EditableChild>
    {
        public static readonly PropertyInfo<string> AssignedByProperty = RegisterProperty<string>(c => c.AssignedBy);
        public string AssignedBy
        {
            get { return GetProperty(AssignedByProperty); }
            private set { LoadProperty(AssignedByProperty, value); }
        }
        public static readonly PropertyInfo<int> DocTypeIDProperty = RegisterProperty<int>(c => c.DocTypeID);
        public int DocTypeID
        {
            get { return GetProperty(DocTypeIDProperty); }
            set { SetProperty(DocTypeIDProperty, value); }
        }
        public static EditableChild New(int docTypeId) { return DataPortal.CreateChild<EditableChild>(docTypeId); }
        void Child_Create(int docTypeId)
        {
            DocTypeID = docTypeId;
            AssignedBy = "AssignedBy" + docTypeId;
        }
       
    }


And I have controller


 


public class ComplexTypeController : Csla.Web.Mvc.Controller, Csla.Web.Mvc.IModelCreator
    {
        //
        // GET: /ComplexType/
        public ActionResult Create()
        {
            EditableRoot type = EditableRoot.New();
            ViewData.Model = type;
            return View();
        }

        [HttpPost]
        public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit)
        {
            if (submit != "Create")
            {
                Random rand = new Random();

                complexType.ChildList.Add(EditableChild.New(rand.Next()));
               
            }
            ViewData.Model = complexType;
            return View();
        }

        public object CreateModel(Type modelType)
        {
            if (modelType == typeof(EditableRoot))
                return EditableRoot.New();
            else if (modelType == typeof(EditableChildList))
                return EditableChildList.New();
            else if (modelType == typeof(EditableChild))
                return EditableChild.New(0);
            else
                return Activator.CreateInstance(modelType);
        }
    }


And I have view


 


@model EditableRoot

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
@using (Html.BeginForm())
{
    @Html.DisplayFor(m => m.Name);
    @Html.HiddenFor(m => m.Id);
    <table>
        <thead>
            <tr>
                <th>Child Type Name</th>
                <td>Child Type Id</td>
            </tr>
        </thead>
        <tbody>
            @for (int i = 0; i < Model.ChildList.Count(); i++)
            {
                <tr>
                    <td>
                        @Html.TextBoxFor(a => Model.ChildListIdea.AssignedBy)
                    </td>
                    <td>
                        @Html.TextBoxFor(a => Model.ChildListIdea.DocTypeID)
                    </td>
                </tr>
            }
        </tbody>
    </table>
   <input name="submit" type="submit" id="submit" value="Create" />
    <input name="submit" type="submit" id="process" value="Add Child" />                       
}

When I add an EditableChild by clicking the "Add Child" button then click the "Create" button the ChildList property of the EditableRoot object in the public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit) call is not bound.


In other words the child list EditableRoot.ChildList is not bound, no items in the list, even though the html in the view follows the conventions for binding lists of complex types. And when I view the actual html in the browser the rows emitted for the items in EditableRoot.ChildList are present and correctly named.


However, I got the CslaModelBinder from github and put it into my project and wired up the mvc default modelbinder to use it. Then I changed the CslaModelBinder method


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)


to look like this


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            {
                //if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                //    return BindCslaCollection(controllerContext, bindingContext);

                var suppress = bindingContext.Model as Csla.Core.ICheckRules;
                if (suppress != null)
                    suppress.SuppressRuleChecking();
                var result = base.BindModel(controllerContext, bindingContext);
                return result;
            }


Everything worked. The EditableRoot.ChildList property is bound, the expected items are in the list.


Ultimately my modification of the CslaModelBinder method


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)


comments out the handling of binding Csla IEditableCollection and so the method ultimately calls the BindModel method on the base class, DefaultModelBinder. Which works.


But, if I use my modified CslaModelBinder will I run into problems elsewhere?


If DefaultModelBinder can handle binding of Csla.Core.IEditableCollection types then why


if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                    return BindCslaCollection(controllerContext, bindingContext);


???

Monday, February 02, 2015  |  From CSLA .NET Contrib

- First the PTracker.mdf and pTracker.ldf were missing and I had to copy them from the zip file


- Got No connection could be made because the target machine actively refused it 127.0.0.1. Change the connection string from (LocalDb)\v11.0 to my sql server instance


-  then I am getting "The provided anti-forgery token was meant for user "manager", but the current user is """.. So I commented out the [ValidateAntiForgeryToken] from the login method


- Now I am getting "UserId not found" error.


The login process is querying the aspnet-MvcUI-20131107034738.AspNetUsers table which is empty.


Why am I encountering so many issues? What am I missing?

Monday, February 02, 2015  |  From CSLA .NET Contrib

The ProjectTracker sample app has a lot of missing references after the installation of CSLA. I spent time add the missing references. The app didn't compile and I found out that it depends on version  1.0 of Microsoft.AspNet.Identity.EntityFramework.dll. The User and Role classes were removed from version 2.1 which is the latest stable version as of now.

Friday, January 30, 2015  |  From CSLA .NET Contrib

(new to CSLA) - I am trying to do some collection validation, but it does not scale.  I would like to write my own method that will loop through the collection without firing any additional events and if I find an object is invalid, I would like to manually set the property to be invalid, which would be reflected through the interface. 

Thursday, January 29, 2015  |  From CSLA .NET Contrib

Hi,


When I try to use DataPortal.ProxyModes as the second parameter in my DataPortal.BeginCreate() method I get the error "Unknown member 'ProxyModes' of 'Csla.DataPortal'"


Has ProxyModes been removed from Csla.DataPortal? I use version 4.5.601 of Csla.


Thanks,


Peter Centellini 

Monday, January 26, 2015  |  From CSLA .NET Contrib

Hi guys, we are using Csla for our business objects, currently using version 3.8.4. There was a requirement to get property value into one of Child's Child object. I was trying to use IParent interface to climb up in hierarchy. But it seems to me i am doing some thing wrong or may be i missed something. Please find attached console test application. i commented out the access path in objB.CheckBsParent() method.


A quick response will be appreciated.


 


Regards.

Thursday, January 22, 2015  |  From CSLA .NET Contrib

Hi,


I have read on many posts about the error message that it is there because we try to write to a collection when it is in ReadOnly mode.


In my case I am setting a property and after that using PropertyHasChanged(string item) method


where the error comes.


The class in which we have used the validation is inheritted from BusinessBAse.


I would like to know where is the best place to set ReadOnlyP propert to False and 


which method shoul I implement and if you can let me know how.


I would appreciate,


Thanks in advance.

Thursday, January 22, 2015  |  From CSLA .NET Contrib

Been using 2.0 framework for quite a few years (obviously).  I am trying to move to to version 3.05 but I am unable to compile due to error.  No modifications have been made to the code.  The error preventing compilation is:


Class: ObjectAdapter


Sub: Fill


Line: 25 className = TypeName (source)


Error: System.RunTime.Serialization.TypeName is not accessible in this context because it is Private.


Anyone have any idea why this is happening?


Appreciate anyone's help.


Jim

Sunday, January 18, 2015  |  From CSLA .NET Contrib

Hi all,


I wonder whether one must really use BindingSource under Windows Forms. Did anyone try doing it without BindingSource?

 CSLA .NET Contrib News Feed 

 Code-gen Templates News Feed 
Monday, March 02, 2015  |  From Code-gen Templates

Dears,


last week i ordered the "Using CSLA Series" eBook, but i received the payment notification received successfully. but i did received the Username and Password to Login and download the eBook. this is since (25 Feb, 2015). any help please ??

Saturday, February 28, 2015  |  From Code-gen Templates

10 years ago I architected a solution where we used CSLA to develop a custom ERP system using CSLA for .Net\WinForms. Now, I am looking to start a similar project and was wondering if this is still a good bet. We need a solid, reliable and Scalable distributed windows framework (some functionality might be extended to web and mobile in the future). I am still interested in a reliable business object framework and CSLA is a familiar entity. Is it still a good bet? Also, CodeSmith seems to be lagging with regards to supporting the latest CSLA versions (is there an up to date template generator out there?). I would appreciate your thoughts and guidance. Thank you in advance.

Friday, February 27, 2015  |  From Code-gen Templates

I am trying to implement object factory support with a read only object and would like to know the best way to populate it.

Friday, February 27, 2015  |  From Code-gen Templates

So I have my MVC project wired up using the latest ASP.Net identity and registration and login works fine. Now to wire into the Csla principal and am wondering how to do this.


How much of the ASP.Net identity bits and pieces can I realistically move into the DalEF project (I'm following the ProjectTracker solution here)?


Anyone tried to implement the SignInManager, UserManager, RoleManager in the Dal like the example simple web membership methods;


Membership.ValidateUser(username, password)


and


var user = Membership.GetUser(username);
var result = new UserDto { Username = username };
result.Roles = Roles.GetRolesForUser(result.Username);
return result;


Thanks.


Richard.


 

Thursday, February 26, 2015  |  From Code-gen Templates

Hello everyone. I have inherited a project that is using CSLA version 1.51.2163.27113. There is a method in the NameValueList component of this assembly named SimpleTableFetch with a signature of CSLA.NameValueList.SimpleTableFetch(String, String, String(), ByRef System.Data.DataTable).


I don't see this method in any of the 1.5 versions of source code on the website. This leads me to guess that the method was added by a previous programmer; but there are no signs of CSLA source code anywhere on my end. I only have DLLs.


Is it possible that this method was part of CSLA at some point; and, if so, where might one find the source code?


Thanks in advance.

Monday, February 23, 2015  |  From Code-gen Templates

Can anyone point me to an example of calling an asynchronous method on a business object from a controller in ASP.Net MVC 5?   Or just show me what the call would be and how the business object method is done.


Currently confused looking at the examples in ProjectTracker, and wondering if GetProjectList<EventHandler<DataPortalResult<ProjectList>> callback) is what I need.


Thanks,
Richard. 


 

Saturday, February 21, 2015  |  From Code-gen Templates

I know MVVM has been around for a number of years.


On October 03, 2011 Rocky wrote on Why MVVM?:



Does MVVM mean you can completely avoid changing code when the XAML changes? No. But it is a whole lot closer than any other technique I’ve seen in my 24+ year career.



 


On May 07, 2012 Rocky wrote on Using the MVVM pattern requires a framework:



In the meantime, Caliburn Micro appears to be the best MVVM framework out there – certainly the most widely used.



 


I guess both the statements are still true:


  • doing MVVM is a must
  • Caliburn.Micro is the best MVVM framework around

It happens some people still develop in Windows Forms. It also happens Visual WebGUI is a Windows Forms look alike, that instead of making desktop applications, makes web applications.


The point is about MVVM and the lack of decent port of a MVVM framework - any framework - to these programming environments. There are a number of partial solutions but nowhere near the real thing.


Interesting enough, people spent more time arguing why MVVM can't be done on Windows Forms and why Caliburn.Micro can't be ported to Windows.Forms than actually trying to do it.


It turns out that since Mar 14, 2012, there was an almost complete port of Caliburn.Micro to Windows Forms hidden among the +100 forks of Caliburn.Micro. Dan Durland is the author of this port.


The MVVM FX Project took it as a starting point. Some major Caliburn.Micro features were missing but now they are working as they should. We can say the port is in beta stage.


Before a formal release announcement is made, a few more samples must be made. A Csla Adapter (ViewModelBase) is planned as well as a Csla sample.


Since there are enough samples to understand how to use the most basic features, you are invited to start using it right now.

Friday, February 13, 2015  |  From Code-gen Templates

I am using CSLA.NET and I have problem with executing long running commands on server from client.Underlying WCF connection is terminated after a minute a client doesn't get a result.


 My idea was to use second command for periodically observing progress of first command (running in new thread) as a benefit I get option get status information and result once is finnished. But unfortunately I can't get it working without getting it too much complex. Any ideas or anything in CSLA which will help me with this?


 

Wednesday, February 11, 2015  |  From Code-gen Templates

I'm looking through the code for Csla, and it seems the check for things like GetObject are done client side before the call is made to the data portal, which is good in that a remote call won't be made if the user lacks permission.


However it doesn't look like the check is repeated on the server side. I can certainly call BusinessRules.HasPermission at the start of each DataPortal_XYZ method, but it feels like the framework should handle this. 


Is if my current understanding is correct and I need to do the check myself in the DataPortal_XYZ methods?


If that is correct, could we get a feature to do this automatically?


This is Csla 4.5.601.

Monday, February 09, 2015  |  From Code-gen Templates

Version 4.5.700 is now available via NuGet and GitHub.


This version primarily adds support for the Xamarin Unified API and new iOS project types, but also includes a number of bug fixes and minor enhancements.


For full details: https://github.com/MarimerLLC/csla/releases/tag/4.5.700

Monday, February 09, 2015  |  From Code-gen Templates

I am trying to write a reusable business rule that would take an editable collection property and an int value and add a broken rule to my root if the count of the collection is greater than the value.


So far, I have written the following business rule but I was hoping you can help me optimize it. Somehow it doesn't feel pretty. I would rather specify the type of the collection which is specified when the property is registered than that of the item.  All I really need to get out of all this is the count of the collection (regardless of the item type).


I am using CSLA 4.3.12


Thanks


 


public class CollectionMaxCountRule<C> : PropertyRule


{


private int MaxCount { get; set; }


 


public CollectionMaxCountRule(IPropertyInfo primaryProperty, int maxCount): base(primaryProperty)


      {


MaxCount = maxCount;


PrimaryProperty = primaryProperty;


InputProperties = new List<IPropertyInfo>() { primaryProperty };


AffectedProperties.Add(primaryProperty);


 


}


 


protected override void Execute(RuleContext context)


{


ICollection<C> _list = (ICollection<C>)context.InputPropertyValues[PrimaryProperty];


 


 


if (_list.Count > MaxCount)


context.AddErrorResult(PrimaryProperty, string.Format("{0} {1}", ResourceFiles.LibraryResources.CollectionMaxCountRule_Error_MaxCount, MaxCount.ToString()));


}


}



 


 It is added using the following:


 





BusinessRules.AddRule(



 



new CollectionMaxCountRule<CostEstimate>(CostEstimateCollectionProperty, int.Parse(ConfigurationManager.AppSettings["MaxCostEstimateCount"])));





 


Wednesday, February 04, 2015  |  From Code-gen Templates

I have the following business classes


 


        public class EditableRoot:Csla.BusinessBase<EditableRoot>
    {
        public string Name { get; private set; }
        public int Id { get; private set; }

        public static EditableRoot New() {
            return DataPortal.Create<EditableRoot>();
        }

        public static readonly PropertyInfo<EditableChildList> ChildListProperty = RegisterProperty<EditableChildList>(c => c.ChildList, RelationshipTypes.Child);
        public EditableChildList ChildList
        {
            get { return GetProperty(ChildListProperty); }
            private set { SetProperty(ChildListProperty, value); }
        }
        protected override void DataPortal_Create()
        {
            ChildList = EditableChildList.New();
        }

    }
    public class EditableChildList : Csla.BusinessListBase<EditableChildList,EditableChild>
    {
        public static EditableChildList New() { return DataPortal.CreateChild<EditableChildList>(); }
    }
    public class EditableChild : Csla.BusinessBase<EditableChild>
    {
        public static readonly PropertyInfo<string> AssignedByProperty = RegisterProperty<string>(c => c.AssignedBy);
        public string AssignedBy
        {
            get { return GetProperty(AssignedByProperty); }
            private set { LoadProperty(AssignedByProperty, value); }
        }
        public static readonly PropertyInfo<int> DocTypeIDProperty = RegisterProperty<int>(c => c.DocTypeID);
        public int DocTypeID
        {
            get { return GetProperty(DocTypeIDProperty); }
            set { SetProperty(DocTypeIDProperty, value); }
        }
        public static EditableChild New(int docTypeId) { return DataPortal.CreateChild<EditableChild>(docTypeId); }
        void Child_Create(int docTypeId)
        {
            DocTypeID = docTypeId;
            AssignedBy = "AssignedBy" + docTypeId;
        }
       
    }


And I have controller


 


public class ComplexTypeController : Csla.Web.Mvc.Controller, Csla.Web.Mvc.IModelCreator
    {
        //
        // GET: /ComplexType/
        public ActionResult Create()
        {
            EditableRoot type = EditableRoot.New();
            ViewData.Model = type;
            return View();
        }

        [HttpPost]
        public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit)
        {
            if (submit != "Create")
            {
                Random rand = new Random();

                complexType.ChildList.Add(EditableChild.New(rand.Next()));
               
            }
            ViewData.Model = complexType;
            return View();
        }

        public object CreateModel(Type modelType)
        {
            if (modelType == typeof(EditableRoot))
                return EditableRoot.New();
            else if (modelType == typeof(EditableChildList))
                return EditableChildList.New();
            else if (modelType == typeof(EditableChild))
                return EditableChild.New(0);
            else
                return Activator.CreateInstance(modelType);
        }
    }


And I have view


 


@model EditableRoot

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
@using (Html.BeginForm())
{
    @Html.DisplayFor(m => m.Name);
    @Html.HiddenFor(m => m.Id);
    <table>
        <thead>
            <tr>
                <th>Child Type Name</th>
                <td>Child Type Id</td>
            </tr>
        </thead>
        <tbody>
            @for (int i = 0; i < Model.ChildList.Count(); i++)
            {
                <tr>
                    <td>
                        @Html.TextBoxFor(a => Model.ChildListIdea.AssignedBy)
                    </td>
                    <td>
                        @Html.TextBoxFor(a => Model.ChildListIdea.DocTypeID)
                    </td>
                </tr>
            }
        </tbody>
    </table>
   <input name="submit" type="submit" id="submit" value="Create" />
    <input name="submit" type="submit" id="process" value="Add Child" />                       
}

When I add an EditableChild by clicking the "Add Child" button then click the "Create" button the ChildList property of the EditableRoot object in the public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit) call is not bound.


In other words the child list EditableRoot.ChildList is not bound, no items in the list, even though the html in the view follows the conventions for binding lists of complex types. And when I view the actual html in the browser the rows emitted for the items in EditableRoot.ChildList are present and correctly named.


However, I got the CslaModelBinder from github and put it into my project and wired up the mvc default modelbinder to use it. Then I changed the CslaModelBinder method


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)


to look like this


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            {
                //if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                //    return BindCslaCollection(controllerContext, bindingContext);

                var suppress = bindingContext.Model as Csla.Core.ICheckRules;
                if (suppress != null)
                    suppress.SuppressRuleChecking();
                var result = base.BindModel(controllerContext, bindingContext);
                return result;
            }


Everything worked. The EditableRoot.ChildList property is bound, the expected items are in the list.


Ultimately my modification of the CslaModelBinder method


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)


comments out the handling of binding Csla IEditableCollection and so the method ultimately calls the BindModel method on the base class, DefaultModelBinder. Which works.


But, if I use my modified CslaModelBinder will I run into problems elsewhere?


If DefaultModelBinder can handle binding of Csla.Core.IEditableCollection types then why


if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                    return BindCslaCollection(controllerContext, bindingContext);


???

Monday, February 02, 2015  |  From Code-gen Templates

- First the PTracker.mdf and pTracker.ldf were missing and I had to copy them from the zip file


- Got No connection could be made because the target machine actively refused it 127.0.0.1. Change the connection string from (LocalDb)\v11.0 to my sql server instance


-  then I am getting "The provided anti-forgery token was meant for user "manager", but the current user is """.. So I commented out the [ValidateAntiForgeryToken] from the login method


- Now I am getting "UserId not found" error.


The login process is querying the aspnet-MvcUI-20131107034738.AspNetUsers table which is empty.


Why am I encountering so many issues? What am I missing?

Monday, February 02, 2015  |  From Code-gen Templates

The ProjectTracker sample app has a lot of missing references after the installation of CSLA. I spent time add the missing references. The app didn't compile and I found out that it depends on version  1.0 of Microsoft.AspNet.Identity.EntityFramework.dll. The User and Role classes were removed from version 2.1 which is the latest stable version as of now.

Friday, January 30, 2015  |  From Code-gen Templates

(new to CSLA) - I am trying to do some collection validation, but it does not scale.  I would like to write my own method that will loop through the collection without firing any additional events and if I find an object is invalid, I would like to manually set the property to be invalid, which would be reflected through the interface. 

Thursday, January 29, 2015  |  From Code-gen Templates

Hi,


When I try to use DataPortal.ProxyModes as the second parameter in my DataPortal.BeginCreate() method I get the error "Unknown member 'ProxyModes' of 'Csla.DataPortal'"


Has ProxyModes been removed from Csla.DataPortal? I use version 4.5.601 of Csla.


Thanks,


Peter Centellini 

Monday, January 26, 2015  |  From Code-gen Templates

Hi guys, we are using Csla for our business objects, currently using version 3.8.4. There was a requirement to get property value into one of Child's Child object. I was trying to use IParent interface to climb up in hierarchy. But it seems to me i am doing some thing wrong or may be i missed something. Please find attached console test application. i commented out the access path in objB.CheckBsParent() method.


A quick response will be appreciated.


 


Regards.

Thursday, January 22, 2015  |  From Code-gen Templates

Hi,


I have read on many posts about the error message that it is there because we try to write to a collection when it is in ReadOnly mode.


In my case I am setting a property and after that using PropertyHasChanged(string item) method


where the error comes.


The class in which we have used the validation is inheritted from BusinessBAse.


I would like to know where is the best place to set ReadOnlyP propert to False and 


which method shoul I implement and if you can let me know how.


I would appreciate,


Thanks in advance.

Thursday, January 22, 2015  |  From Code-gen Templates

Been using 2.0 framework for quite a few years (obviously).  I am trying to move to to version 3.05 but I am unable to compile due to error.  No modifications have been made to the code.  The error preventing compilation is:


Class: ObjectAdapter


Sub: Fill


Line: 25 className = TypeName (source)


Error: System.RunTime.Serialization.TypeName is not accessible in this context because it is Private.


Anyone have any idea why this is happening?


Appreciate anyone's help.


Jim

Sunday, January 18, 2015  |  From Code-gen Templates

Hi all,


I wonder whether one must really use BindingSource under Windows Forms. Did anyone try doing it without BindingSource?

 Code-gen Templates News Feed 

 VS Templates News Feed 
Monday, March 02, 2015  |  From VS Templates

Dears,


last week i ordered the "Using CSLA Series" eBook, but i received the payment notification received successfully. but i did received the Username and Password to Login and download the eBook. this is since (25 Feb, 2015). any help please ??

Saturday, February 28, 2015  |  From VS Templates

10 years ago I architected a solution where we used CSLA to develop a custom ERP system using CSLA for .Net\WinForms. Now, I am looking to start a similar project and was wondering if this is still a good bet. We need a solid, reliable and Scalable distributed windows framework (some functionality might be extended to web and mobile in the future). I am still interested in a reliable business object framework and CSLA is a familiar entity. Is it still a good bet? Also, CodeSmith seems to be lagging with regards to supporting the latest CSLA versions (is there an up to date template generator out there?). I would appreciate your thoughts and guidance. Thank you in advance.

Friday, February 27, 2015  |  From VS Templates

I am trying to implement object factory support with a read only object and would like to know the best way to populate it.

Friday, February 27, 2015  |  From VS Templates

So I have my MVC project wired up using the latest ASP.Net identity and registration and login works fine. Now to wire into the Csla principal and am wondering how to do this.


How much of the ASP.Net identity bits and pieces can I realistically move into the DalEF project (I'm following the ProjectTracker solution here)?


Anyone tried to implement the SignInManager, UserManager, RoleManager in the Dal like the example simple web membership methods;


Membership.ValidateUser(username, password)


and


var user = Membership.GetUser(username);
var result = new UserDto { Username = username };
result.Roles = Roles.GetRolesForUser(result.Username);
return result;


Thanks.


Richard.


 

Thursday, February 26, 2015  |  From VS Templates

Hello everyone. I have inherited a project that is using CSLA version 1.51.2163.27113. There is a method in the NameValueList component of this assembly named SimpleTableFetch with a signature of CSLA.NameValueList.SimpleTableFetch(String, String, String(), ByRef System.Data.DataTable).


I don't see this method in any of the 1.5 versions of source code on the website. This leads me to guess that the method was added by a previous programmer; but there are no signs of CSLA source code anywhere on my end. I only have DLLs.


Is it possible that this method was part of CSLA at some point; and, if so, where might one find the source code?


Thanks in advance.

Monday, February 23, 2015  |  From VS Templates

Can anyone point me to an example of calling an asynchronous method on a business object from a controller in ASP.Net MVC 5?   Or just show me what the call would be and how the business object method is done.


Currently confused looking at the examples in ProjectTracker, and wondering if GetProjectList<EventHandler<DataPortalResult<ProjectList>> callback) is what I need.


Thanks,
Richard. 


 

Saturday, February 21, 2015  |  From VS Templates

I know MVVM has been around for a number of years.


On October 03, 2011 Rocky wrote on Why MVVM?:



Does MVVM mean you can completely avoid changing code when the XAML changes? No. But it is a whole lot closer than any other technique I’ve seen in my 24+ year career.



 


On May 07, 2012 Rocky wrote on Using the MVVM pattern requires a framework:



In the meantime, Caliburn Micro appears to be the best MVVM framework out there – certainly the most widely used.



 


I guess both the statements are still true:


  • doing MVVM is a must
  • Caliburn.Micro is the best MVVM framework around

It happens some people still develop in Windows Forms. It also happens Visual WebGUI is a Windows Forms look alike, that instead of making desktop applications, makes web applications.


The point is about MVVM and the lack of decent port of a MVVM framework - any framework - to these programming environments. There are a number of partial solutions but nowhere near the real thing.


Interesting enough, people spent more time arguing why MVVM can't be done on Windows Forms and why Caliburn.Micro can't be ported to Windows.Forms than actually trying to do it.


It turns out that since Mar 14, 2012, there was an almost complete port of Caliburn.Micro to Windows Forms hidden among the +100 forks of Caliburn.Micro. Dan Durland is the author of this port.


The MVVM FX Project took it as a starting point. Some major Caliburn.Micro features were missing but now they are working as they should. We can say the port is in beta stage.


Before a formal release announcement is made, a few more samples must be made. A Csla Adapter (ViewModelBase) is planned as well as a Csla sample.


Since there are enough samples to understand how to use the most basic features, you are invited to start using it right now.

Friday, February 13, 2015  |  From VS Templates

I am using CSLA.NET and I have problem with executing long running commands on server from client.Underlying WCF connection is terminated after a minute a client doesn't get a result.


 My idea was to use second command for periodically observing progress of first command (running in new thread) as a benefit I get option get status information and result once is finnished. But unfortunately I can't get it working without getting it too much complex. Any ideas or anything in CSLA which will help me with this?


 

Wednesday, February 11, 2015  |  From VS Templates

I'm looking through the code for Csla, and it seems the check for things like GetObject are done client side before the call is made to the data portal, which is good in that a remote call won't be made if the user lacks permission.


However it doesn't look like the check is repeated on the server side. I can certainly call BusinessRules.HasPermission at the start of each DataPortal_XYZ method, but it feels like the framework should handle this. 


Is if my current understanding is correct and I need to do the check myself in the DataPortal_XYZ methods?


If that is correct, could we get a feature to do this automatically?


This is Csla 4.5.601.

Monday, February 09, 2015  |  From VS Templates

Version 4.5.700 is now available via NuGet and GitHub.


This version primarily adds support for the Xamarin Unified API and new iOS project types, but also includes a number of bug fixes and minor enhancements.


For full details: https://github.com/MarimerLLC/csla/releases/tag/4.5.700

Monday, February 09, 2015  |  From VS Templates

I am trying to write a reusable business rule that would take an editable collection property and an int value and add a broken rule to my root if the count of the collection is greater than the value.


So far, I have written the following business rule but I was hoping you can help me optimize it. Somehow it doesn't feel pretty. I would rather specify the type of the collection which is specified when the property is registered than that of the item.  All I really need to get out of all this is the count of the collection (regardless of the item type).


I am using CSLA 4.3.12


Thanks


 


public class CollectionMaxCountRule<C> : PropertyRule


{


private int MaxCount { get; set; }


 


public CollectionMaxCountRule(IPropertyInfo primaryProperty, int maxCount): base(primaryProperty)


      {


MaxCount = maxCount;


PrimaryProperty = primaryProperty;


InputProperties = new List<IPropertyInfo>() { primaryProperty };


AffectedProperties.Add(primaryProperty);


 


}


 


protected override void Execute(RuleContext context)


{


ICollection<C> _list = (ICollection<C>)context.InputPropertyValues[PrimaryProperty];


 


 


if (_list.Count > MaxCount)


context.AddErrorResult(PrimaryProperty, string.Format("{0} {1}", ResourceFiles.LibraryResources.CollectionMaxCountRule_Error_MaxCount, MaxCount.ToString()));


}


}



 


 It is added using the following:


 





BusinessRules.AddRule(



 



new CollectionMaxCountRule<CostEstimate>(CostEstimateCollectionProperty, int.Parse(ConfigurationManager.AppSettings["MaxCostEstimateCount"])));





 


Wednesday, February 04, 2015  |  From VS Templates

I have the following business classes


 


        public class EditableRoot:Csla.BusinessBase<EditableRoot>
    {
        public string Name { get; private set; }
        public int Id { get; private set; }

        public static EditableRoot New() {
            return DataPortal.Create<EditableRoot>();
        }

        public static readonly PropertyInfo<EditableChildList> ChildListProperty = RegisterProperty<EditableChildList>(c => c.ChildList, RelationshipTypes.Child);
        public EditableChildList ChildList
        {
            get { return GetProperty(ChildListProperty); }
            private set { SetProperty(ChildListProperty, value); }
        }
        protected override void DataPortal_Create()
        {
            ChildList = EditableChildList.New();
        }

    }
    public class EditableChildList : Csla.BusinessListBase<EditableChildList,EditableChild>
    {
        public static EditableChildList New() { return DataPortal.CreateChild<EditableChildList>(); }
    }
    public class EditableChild : Csla.BusinessBase<EditableChild>
    {
        public static readonly PropertyInfo<string> AssignedByProperty = RegisterProperty<string>(c => c.AssignedBy);
        public string AssignedBy
        {
            get { return GetProperty(AssignedByProperty); }
            private set { LoadProperty(AssignedByProperty, value); }
        }
        public static readonly PropertyInfo<int> DocTypeIDProperty = RegisterProperty<int>(c => c.DocTypeID);
        public int DocTypeID
        {
            get { return GetProperty(DocTypeIDProperty); }
            set { SetProperty(DocTypeIDProperty, value); }
        }
        public static EditableChild New(int docTypeId) { return DataPortal.CreateChild<EditableChild>(docTypeId); }
        void Child_Create(int docTypeId)
        {
            DocTypeID = docTypeId;
            AssignedBy = "AssignedBy" + docTypeId;
        }
       
    }


And I have controller


 


public class ComplexTypeController : Csla.Web.Mvc.Controller, Csla.Web.Mvc.IModelCreator
    {
        //
        // GET: /ComplexType/
        public ActionResult Create()
        {
            EditableRoot type = EditableRoot.New();
            ViewData.Model = type;
            return View();
        }

        [HttpPost]
        public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit)
        {
            if (submit != "Create")
            {
                Random rand = new Random();

                complexType.ChildList.Add(EditableChild.New(rand.Next()));
               
            }
            ViewData.Model = complexType;
            return View();
        }

        public object CreateModel(Type modelType)
        {
            if (modelType == typeof(EditableRoot))
                return EditableRoot.New();
            else if (modelType == typeof(EditableChildList))
                return EditableChildList.New();
            else if (modelType == typeof(EditableChild))
                return EditableChild.New(0);
            else
                return Activator.CreateInstance(modelType);
        }
    }


And I have view


 


@model EditableRoot

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
@using (Html.BeginForm())
{
    @Html.DisplayFor(m => m.Name);
    @Html.HiddenFor(m => m.Id);
    <table>
        <thead>
            <tr>
                <th>Child Type Name</th>
                <td>Child Type Id</td>
            </tr>
        </thead>
        <tbody>
            @for (int i = 0; i < Model.ChildList.Count(); i++)
            {
                <tr>
                    <td>
                        @Html.TextBoxFor(a => Model.ChildListIdea.AssignedBy)
                    </td>
                    <td>
                        @Html.TextBoxFor(a => Model.ChildListIdea.DocTypeID)
                    </td>
                </tr>
            }
        </tbody>
    </table>
   <input name="submit" type="submit" id="submit" value="Create" />
    <input name="submit" type="submit" id="process" value="Add Child" />                       
}

When I add an EditableChild by clicking the "Add Child" button then click the "Create" button the ChildList property of the EditableRoot object in the public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit) call is not bound.


In other words the child list EditableRoot.ChildList is not bound, no items in the list, even though the html in the view follows the conventions for binding lists of complex types. And when I view the actual html in the browser the rows emitted for the items in EditableRoot.ChildList are present and correctly named.


However, I got the CslaModelBinder from github and put it into my project and wired up the mvc default modelbinder to use it. Then I changed the CslaModelBinder method


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)


to look like this


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            {
                //if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                //    return BindCslaCollection(controllerContext, bindingContext);

                var suppress = bindingContext.Model as Csla.Core.ICheckRules;
                if (suppress != null)
                    suppress.SuppressRuleChecking();
                var result = base.BindModel(controllerContext, bindingContext);
                return result;
            }


Everything worked. The EditableRoot.ChildList property is bound, the expected items are in the list.


Ultimately my modification of the CslaModelBinder method


public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)


comments out the handling of binding Csla IEditableCollection and so the method ultimately calls the BindModel method on the base class, DefaultModelBinder. Which works.


But, if I use my modified CslaModelBinder will I run into problems elsewhere?


If DefaultModelBinder can handle binding of Csla.Core.IEditableCollection types then why


if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                    return BindCslaCollection(controllerContext, bindingContext);


???

Monday, February 02, 2015  |  From VS Templates

- First the PTracker.mdf and pTracker.ldf were missing and I had to copy them from the zip file


- Got No connection could be made because the target machine actively refused it 127.0.0.1. Change the connection string from (LocalDb)\v11.0 to my sql server instance


-  then I am getting "The provided anti-forgery token was meant for user "manager", but the current user is """.. So I commented out the [ValidateAntiForgeryToken] from the login method


- Now I am getting "UserId not found" error.


The login process is querying the aspnet-MvcUI-20131107034738.AspNetUsers table which is empty.


Why am I encountering so many issues? What am I missing?

Monday, February 02, 2015  |  From VS Templates

The ProjectTracker sample app has a lot of missing references after the installation of CSLA. I spent time add the missing references. The app didn't compile and I found out that it depends on version  1.0 of Microsoft.AspNet.Identity.EntityFramework.dll. The User and Role classes were removed from version 2.1 which is the latest stable version as of now.

Friday, January 30, 2015  |  From VS Templates

(new to CSLA) - I am trying to do some collection validation, but it does not scale.  I would like to write my own method that will loop through the collection without firing any additional events and if I find an object is invalid, I would like to manually set the property to be invalid, which would be reflected through the interface. 

Thursday, January 29, 2015  |  From VS Templates

Hi,


When I try to use DataPortal.ProxyModes as the second parameter in my DataPortal.BeginCreate() method I get the error "Unknown member 'ProxyModes' of 'Csla.DataPortal'"


Has ProxyModes been removed from Csla.DataPortal? I use version 4.5.601 of Csla.


Thanks,


Peter Centellini 

Monday, January 26, 2015  |  From VS Templates

Hi guys, we are using Csla for our business objects, currently using version 3.8.4. There was a requirement to get property value into one of Child's Child object. I was trying to use IParent interface to climb up in hierarchy. But it seems to me i am doing some thing wrong or may be i missed something. Please find attached console test application. i commented out the access path in objB.CheckBsParent() method.


A quick response will be appreciated.


 


Regards.

Thursday, January 22, 2015  |  From VS Templates

Hi,


I have read on many posts about the error message that it is there because we try to write to a collection when it is in ReadOnly mode.


In my case I am setting a property and after that using PropertyHasChanged(string item) method


where the error comes.


The class in which we have used the validation is inheritted from BusinessBAse.


I would like to know where is the best place to set ReadOnlyP propert to False and 


which method shoul I implement and if you can let me know how.


I would appreciate,


Thanks in advance.

Thursday, January 22, 2015  |  From VS Templates

Been using 2.0 framework for quite a few years (obviously).  I am trying to move to to version 3.05 but I am unable to compile due to error.  No modifications have been made to the code.  The error preventing compilation is:


Class: ObjectAdapter


Sub: Fill


Line: 25 className = TypeName (source)


Error: System.RunTime.Serialization.TypeName is not accessible in this context because it is Private.


Anyone have any idea why this is happening?


Appreciate anyone's help.


Jim

Sunday, January 18, 2015  |  From VS Templates

Hi all,


I wonder whether one must really use BindingSource under Windows Forms. Did anyone try doing it without BindingSource?

 VS Templates News Feed 

Last edited Jan 18, 2007 at 7:55 PM by RockfordLhotka, version 2

Comments

No comments yet.