CSLA .NET Contrib News Feed 
Monday, May 20, 2013  |  From CSLA .NET Contrib

I'm having a problem during a SaveAsync method call in my Silverlight ViewModelBase. When my model 's graph gets too bloated, the "clone" and "undo" routines are taking a long time and the window gets stuck due to the synchronous process, if the user try to click on screen, the browser crashes. Consider putting the "clone" and "undo" routines in a task.


code: http://take.ms/VxPdtq

Monday, May 20, 2013  |  From CSLA .NET Contrib


I
have a rule in my children objects that uses some values from the parent
object. The rule must be executed when any of those values in the parent
changes. The rule also adds different error result messages depending of
certain conditions.


The options I have are:


1-Add the needed properties to
the child object and update its values every time the values in the parent
change using PropertyHasChanged. Those properties have to be loaded also for
every new child and when the children objects are being load from the database.


What I don't like about this
approach is to add properties to the child that don't really belong
there and all the code needed to load those properties.


 2-Create
a lambda rule in the child that uses the values from the parent through the
Parent property of the child object. Add some method in the child object to
call BusinessRules.CheckRules(MyProperty). That method will be used from the
parent object inside PropertyHasChanged to trigger the execution of the rule in
the children.


In
this option I don't know how to output different messages for the rule
depending of conditions inside the rule code. This is how I define the rule:


BusinessRules.AddRule<MyChild>(MyPropertyProperty,


o
=> {


                …rule code here using (MyParent)o.Parent


},
“Broken rule message”);


 


My
questions are:


Is
there a better solution for this?


If
not, how can I output different messages from the rule using the second option?


Thanks in advance.


Monday, May 20, 2013  |  From CSLA .NET Contrib

Guys, hope eveyone is well, but need some advice.


I have a class, and that class has children.  Each child is going to connect to a database, calculate some values and return.  At the moment this run in sync, so i loop through each child, connect to database, get result and move on to the next one.


This works fine, but i think running the code in async mode would benefit performance.


I seen this on microsoft site http://msdn.microsoft.com/en-us/library/3dasc8as(v=vs.80).aspx describing how to use a ThreadPool to execute async tasks, and the code waits until all the tasks are finished.  This sounds exactly like what i want to do, but i understand the Prinical objects etc are not copied over into other threads? I am using asp.net 4.0.


I havent done much async processing, and none where i need to carry the current prinical object.


I have seen that Csla has a backgroundWorker which does pass on the prinicipal values etc.  Is there a limit on the number of BackgroundWorkers i can create?  How would i wait for all backgroundworkers to complete?


Sorry i this is basic, but thought i would ask here as maybe someone else has had this problem as well

Monday, May 20, 2013  |  From CSLA .NET Contrib

Hello,


I am experiencing a problem with CSLA that didn't seem to be in the forums, until last week when someone else was experiencing the same problems as me. the post the question is in is marked with a suggested answer so this might be the reason why you have not seen it. however I am reposting it here in hope for a answer.


---------------------------------------------------------------------------------------------------------------------------------------------------------


 Original Post from  Cymro in forum post Error when pressing escape key on a filtered list bound datagridview


---------------------------------------------------------------------------------------------------------------------------------------------------------


I have tested this further and it appears that there are other issues around the CancelNew behaviour with a DataGridView.  The reason I was looking at this was because we are attempting to use a SortedBindingList and FilteredBindingList with a DynamicBindingListBase derived class.  The issue here is that when the list is Sorted (or filtered) the cancel new fails and leaves the invalid new item in the list.


I have tracked this down and found the issue but not a satisfactory resolution Tongue Tied


When a new row is added to a DataGridView the AddNew adds the object to the end of the list.  Even if the sorted is list is sorted it still goes at the end of the sorted list (which is what we want).


The issue is with the way that the DataGridView's DataBinding handles the cancelling. 


  1. The DataGridView calls CancelEdit on the child object through (IEditableObject.CancelEdit). 
  2. The changes get rolled back in the child object, but this has the side effect of raising OnUnknownPropertyChanged.
  3. PropertyChanged is handled by the parent BindingList and raises the IBindingList.ListChanged event with a ListChangeType of "Reset". 
  4. The SortedBindingList handles the ListChanged of the source list and calls DoSort, resorting all the items in the list (including the new item).  This is where the problem lies!!!
  5. The DataGridView then calls ICancelAddNew.CancelNew passing the last row index - but this is no longer where our item is, because it has been re-sorted into the middle of the list somewhere.

We do not see the effect of this issue in a BusinessBindingListBase because as part of the CancelEdit on the child, it calls to the parent list to remove it (when the EditLevel < EditLevelAdded) using IParent.RemoveChild(T child).  With a BusinessBindingListBase the implementation of this method removes the child, whereas with a DynamicBindingList does not.  Therefore, with a BusinessBindingListBase the new child is removed from the list before the CancelNew is even called (as part of step 2 above) which masks the issue with the CancelNew implementation of the SortedBindingList.


I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...


...suggests that this was thought about and decided this should not be done here.  And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.


Now the obvious "fix" is to have the DynamicBindingList remove the child as part of the IParent.RemoveChild implementation as follows...


    /// <summary>
/// This method is called by a child object when it
/// wants to be removed from the collection.
/// </summary>
/// <param name="child">The child object to remove.</param>
void Core.IEditableCollection.RemoveChild(Csla.Core.IEditableBusinessObject child)
{

      Remove((C)child);
}

I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...


      // do nothing, removal of a child is handled by
      // the RemoveItem override


...suggests that this was thought about and decided this should not be done here. And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.  Does anyone have any thoughts?


---------------------------------------------------------------------------------------------------------------------------------------------------------


EDIT:


---------------------------------------------------------------------------------------------------------------------------------------------------------


Forgot to mention that I am using CSLA 4.0.1 and have also tried this on 4.2.something

Thursday, May 16, 2013  |  From CSLA .NET Contrib

Greetings:


I've a Silverlight application that needs to have a static class called "Settings".   This class will be a read only base class with about 2 dozen settings that should be available anywhere in the UI layer.  I'm not really sure where the best place to put that class might be ... that is, the best place to have the system make an async call to load up the settings.


Maybe Application_Startup?


Thoughts?

Thursday, May 16, 2013  |  From CSLA .NET Contrib

When I remove an item from a Dynamic List, Shouldn't the Update be called right away?  Here is the code from the View Model:


        private void OnDeleteSessionConfirmDialogClosed(IMessageBox messageBox)


        {


            if (messageBox.WasSelected(MessageBoxButtons.Yes))


            {


                Model.SessionList.Remove(Session);


            }


        }



I tried to save after it was removed, but the object was marked as busy and I couldn't apply edits:



        private void OnDeleteSessionConfirmDialogClosed(IMessageBox messageBox)


        {


            if (messageBox.WasSelected(MessageBoxButtons.Yes))


            {


                Model.SessionList.Remove(Session);


                Session.ApplyEdit();


                Session.BeginSave((o, e) =>


                    {


                        if (e.Error != null)


                        {


                            throw e.Error;


                        }                        


                    });


            }


        }



I don't think I need to do this as the Dynamic List should save automatically...Correct?  It does dissappear off the list in the datagrid, but it never disappears from the database...any help would be appreciated!  I am using Silverlight 5 with CSLA 4.3 (I believe).


Todd


 


Wednesday, May 15, 2013  |  From CSLA .NET Contrib

My use case scenario has defined these objects: Employee, User, Client.  My database is structured similar to inheritance where the base table is named Entity (id, displayname) with a one to one relationship to Person(entityId, firstname, lastname) with a one to one to Employee/User/Client(entityId, …) tables each containing their unique fields. An Entity can be one or all three of the use case objects.


I’ve created working business objects using code generation which creates an Entity with child property of Person with child properties for Employee, User and Client.  Everything is fairly straightforward in that binding is done using dot notation like Entity.Person.Employee.HireDate.  I’ve also created properties IsEmployee, IsClient, IsUser which checks for null on those properties.


In Rocky’s book he talks about responsibility driven design which seems to infer that my business objects should be redesigned like Employee(entityId, displayname, firstname, lastname, hiredate).  But this would create challenges when updating the database.  (I’m using ado for data access).


I haven’t run into any real problems with my current business object design, but in my desire to understand best practices I am curious if I should redo my business objects, perhaps learning and implementing EF as a my data access?

Wednesday, May 15, 2013  |  From CSLA .NET Contrib

My Dev team is having issues to incorporate Silverlight with Bxf in the CSLA 4.0 Factory Model, that has to call the wcf to fetch the data from database.

Has anybody faced similar issues? Any help in this regard is appreciated as we are hitting the wall at this time!

Wednesday, May 15, 2013  |  From CSLA .NET Contrib

Hello,


We are facing issues to incorporate Silverlight with Bxf in the Factory Model. That has to call the wcf to fetch the data from database. In case if you have some specific videos where in you have incorporated this entire process please suggest.


 

Tuesday, May 14, 2013  |  From CSLA .NET Contrib

Upgrade to Csla 4.5.30


This release depends on CSLA .NET 4.5.30 and is also available on NuGet


Changes since CSLA .NET Contrib version 4.3.16



  • Refactor CslaContrib.Caliburn.Micro to Csla 4.5.30
  • Refactor ObjectCaching to Csla 4.5.30
  • Updated Caliburn.Micro to 1.5.1
  • Removed Silverlight 4 projects
  • Added NET 4.5 projects
  • New project CslaContrib for Silverlight 5
  • New projects CslaContrib.MEF for Silverlight 5 and WinRT

CSLA .NET Contrib 4.5.30 release notes and download

Tuesday, May 14, 2013  |  From CSLA .NET Contrib

Hi I am using CSLA 4.3.10.0 in a multi tier application which uses WCF in IIS 6. The WCFconfig uses the standard 'wsHttpBinding' binding with no compression.


Recently whilst testing a new app I started seeing strange exceptions whenever the remote client attempted to save data to the app server. I traced the issue down to the default 8MB limit that IIS placec on transfers.


The remote client was actually parsing some csv and xml files to create a list of dirty objects, so it was fairly easy to creat a large set of dirty objects. I was able to work around the problem by  breaking up the upload into several smaller chunks, I noticed something that has raised my curiosity.


I never saw issues when retreiving data from the app server, even though the retrieved data  contained exactly the same objects that weretoo large to save (upload). Using Fidler I saw that the size of the uploaded data (dirty objects) was around 10x the size of the retrieved (downloaded) data (I undid the chunking for the tests).


 


Is there a reason for this discrepancy in size?


Is there any safe way to reduce the upload size?


 


Thanks


Kosta

Sunday, May 12, 2013  |  From CSLA .NET Contrib

Maintenance release (update to Csla 4.3.14)


This release depends on CSLA .NET 4.3.14 and is also available on NuGet


Changes since CSLA .NET Contrib 4.3.13



  • Updated MEF call to only use SatisfyImportsOnce() to compose object
  • Upgraded rules and added NoDuplicates rule
  • NuGet packages dependency improvements

CSLA .NET Contrib 4.3.16 release notes and download

Saturday, May 11, 2013  |  From CSLA .NET Contrib

Hello,


I have a business object for which I need to make some validations that involve several properties of the object and more data that I will need to read from the database. I'm using this object in an MVC application and I though that will be better to run this validation once, after all the related properties are set. In other objects with regular rules I usually suppress the rule checks, set all the properties and then call CheckRules before saving.


Should I use a Per-Type rule? I was looking the ebook "Creating business objects" and couldn't find any example or to much detail about per-type rules.


I would like somebody to point me in the right direction.


Thanks in advance.

Friday, May 10, 2013  |  From CSLA .NET Contrib

I am using the CSLA 3.x framework.


This is my Unit Test method for the DataProtal Create method for one of our business objects.  Should I add anymore to it?


        /// <summary>
        ///A test for DataPortal_Create
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Cit.Library.dll")]
        public void DataPortal_CreateTest()
        {
            Person person = Person.GetPerson(false, 1);


            Cit_Accessor target = new Cit_Accessor();
            object criteria = new Cit_Accessor.Criteria(1, Person);


            target.DataPortal_Create(criteria);


            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

Friday, May 10, 2013  |  From CSLA .NET Contrib

Hello,


I have a Silverlight CSLA project in VS2010 and it had been working with 4.3+ just fine. Then I upgraded to 4.5.10 when that was released using Nuget. Unknown at the time, the BeginSave method would fail to call the Saved event if an exception was thrown in the DataPortal_Update method. I didn't test any other scenarios. It used to be called in the 4.3.x version. The Csla.Xaml.ViewModel.BeginSave depends on the Saved event, so I suspect the new behavior is not expected.


Using the following code, the same differing results were generated when referencing the specified versions.


        private static void Main()
        {
            var obj = MyBusiness.Get(2);
            obj.Id = 3;
            obj.Saved += (o, e) => Debug.WriteLine("Saved");
            obj.BeginSave();
 
            Console.ReadKey();
        }
 
        [Serializable]
        public class MyBusiness : BusinessBase<MyBusiness>
        {
            public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
            public int Id
            {
                get { return GetProperty(IdProperty); }
                set { SetProperty(IdProperty, value); }
            }
 
            public static MyBusiness Get(int id)
            {
                return DataPortal.Fetch<MyBusiness>(id);
            }
 
            private void DataPortal_Fetch(int id)
            {
                using (BypassPropertyChecks)
                {
                    Id = id;
                }
            }
 
            protected override void DataPortal_Update()
            {
                throw new Exception("Failure");
            }
        }

Is there a bug in 4.5+ or is the behavior because I'm using version 4.5.10 in VS2010?

Friday, May 10, 2013  |  From CSLA .NET Contrib

CSLA 4 version 4.5.30 is now available via nuget and the download page.


This version includes a number of bug fixes and some new features and is a recommended upgrade from 4.5.20.


Perhaps the biggest new feature is the ability to create classes that are invoked by the server-side data portal to simplify the use of IoC containers and DI as the data portal creates and interacts with root objects on the server. See the CustomActivator sample to see how this works.


Here's a list of changes:


https://github.com/MarimerLLC/csla/issues?milestone=4&state=closed

Friday, May 10, 2013  |  From CSLA .NET Contrib

CSLA 4 version 4.3.14 is now available via nuget.

This version adds support for DateTimeOffset to SafeDataReader, addresses a MobileFormatter deserialization bug, and fixes an issue with warnings in CslaActionExtender.

As a result it is a relatively minor bug fix update from 4.3.13.


Change list:


https://github.com/MarimerLLC/csla/issues?milestone=5&state=closed

Thursday, May 09, 2013  |  From CSLA .NET Contrib

I am trying to code a unit test for one of our business objects but I had a question about the way I am calling the dataprotal create method.  Here is a code snippets.  Should I not use a criteria class?  It passes in another business object that is inherited form the csla framework.


         [Serializable()]
        private class Criteria
        {
            public string RecordNo = string.Empty;
            public Person LoggedInPerson;
            public Criteria(string recordNo, Person LoggedInPerson)
            {
                this.RecordNo = recordNo;
                LoggedInPerson = LoggedInPerson;
            }
        }


        [RunLocal()]
        protected void DataPortal_Create(object criteria)
        {
            Criteria crit = (Criteria)criteria;


            //...


            ValidationRules.CheckRules();


        }

Thursday, May 09, 2013  |  From CSLA .NET Contrib

Hi,


When i want to fetch record from CSLA it's giving error , we are using CSLA version 1 with window 7, 


please help me.


ExceptionSource: Csla: DataPortalException: DataPortal.Fetch failed ()
ExceptionDetail:
Csla.DataPortalException: DataPortal.Fetch failed () --->
System.NullReferenceException: Object reference not set to an instance
of an object.
at Csla.Server.CallMethodException..ctor(String
message, Exception ex) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Server\CallMethodException.cs:line
44
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info,
Object[] parameters) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\MethodCaller.cs:line 118
at
Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria,
DataPortalContext context) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Server\SimpleDataPortal.cs:line
109
--- End of inner exception stack trace ---
at
Csla.DataPortal.Fetch(Type objectType, Object criteria) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 192
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Tools\CSLA\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 140


 


Thanks,


Vivek

Wednesday, May 08, 2013  |  From CSLA .NET Contrib

What is the best approach for implementing a per-property authorization rule that depends on the result of an async, lazy-loaded property?


Here's my suggestion:


 


[Serializable]


public sealed class Parent : BusinessBase<Parent>


{


public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(c => c.Name);


public string Name


{


get { return GetProperty(NameProperty); }


set { SetProperty(NameProperty, value); }


}



public static readonly PropertyInfo<ChildrenList> ChildrenProperty = RegisterProperty<ChildrenList>(c => c.Children, RelationshipTypes.Child | RelationshipTypes.LazyLoad);


public ChildrenList Children


{


get


{


if (!FieldManager.FieldExists(ChildrenProperty))


{


if (IsNew)


LoadProperty(ChildrenProperty, ChildrenList.NewList());


else


{


ChildrenList.GetListAsync(Id, (o, e) =>


{


if (e.Error != null)


throw e.Error;


LoadProperty(ChildrenProperty, e.Object);


OnPropertyChanged(ChildrenProperty);


});


return null;


}


}


return GetProperty(ChildrenProperty);


}


}



protected override void AddBusinessRules()


{


base.AddBusinessRules();


BusinessRules.AddRule(new Required(NameProperty));


BusinessRules.AddRule(new MaxLength(NameProperty, 255));


BusinessRules.AddRule(new CanWriteParentNameRule(AuthorizationActions.WriteProperty, NameProperty));


BusinessRules.AddRule(new Dependency(ChildrenProperty, NameProperty));


}


}


 


public class CanWriteParentNameRule : AuthorizationRule


{


public CanWriteParentNameRule(AuthorizationActions action, IMemberInfo element)


: base(action, element) { }


 


protected override void Execute(AuthorizationContext context)


{


var parent = context.Target as Parent;


 


if (parent != null && parent.Children != null)


context.HasPermission = (parent.Children.Count == 0);


else


context.HasPermission = false;


}


}


The binding of the name property causes the authorization rule to be evaluated which in turn triggers the async retrieval by accessing the Children property. The property returns null and we default HasPermission to false until we have the children.


When the Children property eventually returns, it raises OnPropertyChanged which in turn (via the Dependency business rule) causes the name property rules to be re-evaluated including the authorization rule. This time the authorization rule gets the children and sets HasPermission accordingly.


What do you think? Does this seem plausible?


Thanks in advance,



Joe

 

 CSLA .NET Contrib News Feed 

 Code-gen Templates News Feed 
Monday, May 20, 2013  |  From Code-gen Templates

I'm having a problem during a SaveAsync method call in my Silverlight ViewModelBase. When my model 's graph gets too bloated, the "clone" and "undo" routines are taking a long time and the window gets stuck due to the synchronous process, if the user try to click on screen, the browser crashes. Consider putting the "clone" and "undo" routines in a task.


code: http://take.ms/VxPdtq

Monday, May 20, 2013  |  From Code-gen Templates


I
have a rule in my children objects that uses some values from the parent
object. The rule must be executed when any of those values in the parent
changes. The rule also adds different error result messages depending of
certain conditions.


The options I have are:


1-Add the needed properties to
the child object and update its values every time the values in the parent
change using PropertyHasChanged. Those properties have to be loaded also for
every new child and when the children objects are being load from the database.


What I don't like about this
approach is to add properties to the child that don't really belong
there and all the code needed to load those properties.


 2-Create
a lambda rule in the child that uses the values from the parent through the
Parent property of the child object. Add some method in the child object to
call BusinessRules.CheckRules(MyProperty). That method will be used from the
parent object inside PropertyHasChanged to trigger the execution of the rule in
the children.


In
this option I don't know how to output different messages for the rule
depending of conditions inside the rule code. This is how I define the rule:


BusinessRules.AddRule<MyChild>(MyPropertyProperty,


o
=> {


                …rule code here using (MyParent)o.Parent


},
“Broken rule message”);


 


My
questions are:


Is
there a better solution for this?


If
not, how can I output different messages from the rule using the second option?


Thanks in advance.


Monday, May 20, 2013  |  From Code-gen Templates

Guys, hope eveyone is well, but need some advice.


I have a class, and that class has children.  Each child is going to connect to a database, calculate some values and return.  At the moment this run in sync, so i loop through each child, connect to database, get result and move on to the next one.


This works fine, but i think running the code in async mode would benefit performance.


I seen this on microsoft site http://msdn.microsoft.com/en-us/library/3dasc8as(v=vs.80).aspx describing how to use a ThreadPool to execute async tasks, and the code waits until all the tasks are finished.  This sounds exactly like what i want to do, but i understand the Prinical objects etc are not copied over into other threads? I am using asp.net 4.0.


I havent done much async processing, and none where i need to carry the current prinical object.


I have seen that Csla has a backgroundWorker which does pass on the prinicipal values etc.  Is there a limit on the number of BackgroundWorkers i can create?  How would i wait for all backgroundworkers to complete?


Sorry i this is basic, but thought i would ask here as maybe someone else has had this problem as well

Monday, May 20, 2013  |  From Code-gen Templates

Hello,


I am experiencing a problem with CSLA that didn't seem to be in the forums, until last week when someone else was experiencing the same problems as me. the post the question is in is marked with a suggested answer so this might be the reason why you have not seen it. however I am reposting it here in hope for a answer.


---------------------------------------------------------------------------------------------------------------------------------------------------------


 Original Post from  Cymro in forum post Error when pressing escape key on a filtered list bound datagridview


---------------------------------------------------------------------------------------------------------------------------------------------------------


I have tested this further and it appears that there are other issues around the CancelNew behaviour with a DataGridView.  The reason I was looking at this was because we are attempting to use a SortedBindingList and FilteredBindingList with a DynamicBindingListBase derived class.  The issue here is that when the list is Sorted (or filtered) the cancel new fails and leaves the invalid new item in the list.


I have tracked this down and found the issue but not a satisfactory resolution Tongue Tied


When a new row is added to a DataGridView the AddNew adds the object to the end of the list.  Even if the sorted is list is sorted it still goes at the end of the sorted list (which is what we want).


The issue is with the way that the DataGridView's DataBinding handles the cancelling. 


  1. The DataGridView calls CancelEdit on the child object through (IEditableObject.CancelEdit). 
  2. The changes get rolled back in the child object, but this has the side effect of raising OnUnknownPropertyChanged.
  3. PropertyChanged is handled by the parent BindingList and raises the IBindingList.ListChanged event with a ListChangeType of "Reset". 
  4. The SortedBindingList handles the ListChanged of the source list and calls DoSort, resorting all the items in the list (including the new item).  This is where the problem lies!!!
  5. The DataGridView then calls ICancelAddNew.CancelNew passing the last row index - but this is no longer where our item is, because it has been re-sorted into the middle of the list somewhere.

We do not see the effect of this issue in a BusinessBindingListBase because as part of the CancelEdit on the child, it calls to the parent list to remove it (when the EditLevel < EditLevelAdded) using IParent.RemoveChild(T child).  With a BusinessBindingListBase the implementation of this method removes the child, whereas with a DynamicBindingList does not.  Therefore, with a BusinessBindingListBase the new child is removed from the list before the CancelNew is even called (as part of step 2 above) which masks the issue with the CancelNew implementation of the SortedBindingList.


I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...


...suggests that this was thought about and decided this should not be done here.  And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.


Now the obvious "fix" is to have the DynamicBindingList remove the child as part of the IParent.RemoveChild implementation as follows...


    /// <summary>
/// This method is called by a child object when it
/// wants to be removed from the collection.
/// </summary>
/// <param name="child">The child object to remove.</param>
void Core.IEditableCollection.RemoveChild(Csla.Core.IEditableBusinessObject child)
{

      Remove((C)child);
}

I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...


      // do nothing, removal of a child is handled by
      // the RemoveItem override


...suggests that this was thought about and decided this should not be done here. And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.  Does anyone have any thoughts?


---------------------------------------------------------------------------------------------------------------------------------------------------------


EDIT:


---------------------------------------------------------------------------------------------------------------------------------------------------------


Forgot to mention that I am using CSLA 4.0.1 and have also tried this on 4.2.something

Thursday, May 16, 2013  |  From Code-gen Templates

Greetings:


I've a Silverlight application that needs to have a static class called "Settings".   This class will be a read only base class with about 2 dozen settings that should be available anywhere in the UI layer.  I'm not really sure where the best place to put that class might be ... that is, the best place to have the system make an async call to load up the settings.


Maybe Application_Startup?


Thoughts?

Thursday, May 16, 2013  |  From Code-gen Templates

When I remove an item from a Dynamic List, Shouldn't the Update be called right away?  Here is the code from the View Model:


        private void OnDeleteSessionConfirmDialogClosed(IMessageBox messageBox)


        {


            if (messageBox.WasSelected(MessageBoxButtons.Yes))


            {


                Model.SessionList.Remove(Session);


            }


        }



I tried to save after it was removed, but the object was marked as busy and I couldn't apply edits:



        private void OnDeleteSessionConfirmDialogClosed(IMessageBox messageBox)


        {


            if (messageBox.WasSelected(MessageBoxButtons.Yes))


            {


                Model.SessionList.Remove(Session);


                Session.ApplyEdit();


                Session.BeginSave((o, e) =>


                    {


                        if (e.Error != null)


                        {


                            throw e.Error;


                        }                        


                    });


            }


        }



I don't think I need to do this as the Dynamic List should save automatically...Correct?  It does dissappear off the list in the datagrid, but it never disappears from the database...any help would be appreciated!  I am using Silverlight 5 with CSLA 4.3 (I believe).


Todd


 


Wednesday, May 15, 2013  |  From Code-gen Templates

My use case scenario has defined these objects: Employee, User, Client.  My database is structured similar to inheritance where the base table is named Entity (id, displayname) with a one to one relationship to Person(entityId, firstname, lastname) with a one to one to Employee/User/Client(entityId, …) tables each containing their unique fields. An Entity can be one or all three of the use case objects.


I’ve created working business objects using code generation which creates an Entity with child property of Person with child properties for Employee, User and Client.  Everything is fairly straightforward in that binding is done using dot notation like Entity.Person.Employee.HireDate.  I’ve also created properties IsEmployee, IsClient, IsUser which checks for null on those properties.


In Rocky’s book he talks about responsibility driven design which seems to infer that my business objects should be redesigned like Employee(entityId, displayname, firstname, lastname, hiredate).  But this would create challenges when updating the database.  (I’m using ado for data access).


I haven’t run into any real problems with my current business object design, but in my desire to understand best practices I am curious if I should redo my business objects, perhaps learning and implementing EF as a my data access?

Wednesday, May 15, 2013  |  From Code-gen Templates

My Dev team is having issues to incorporate Silverlight with Bxf in the CSLA 4.0 Factory Model, that has to call the wcf to fetch the data from database.

Has anybody faced similar issues? Any help in this regard is appreciated as we are hitting the wall at this time!

Wednesday, May 15, 2013  |  From Code-gen Templates

Hello,


We are facing issues to incorporate Silverlight with Bxf in the Factory Model. That has to call the wcf to fetch the data from database. In case if you have some specific videos where in you have incorporated this entire process please suggest.


 

Tuesday, May 14, 2013  |  From Code-gen Templates

Upgrade to Csla 4.5.30


This release depends on CSLA .NET 4.5.30 and is also available on NuGet


Changes since CSLA .NET Contrib version 4.3.16



  • Refactor CslaContrib.Caliburn.Micro to Csla 4.5.30
  • Refactor ObjectCaching to Csla 4.5.30
  • Updated Caliburn.Micro to 1.5.1
  • Removed Silverlight 4 projects
  • Added NET 4.5 projects
  • New project CslaContrib for Silverlight 5
  • New projects CslaContrib.MEF for Silverlight 5 and WinRT

CSLA .NET Contrib 4.5.30 release notes and download

Tuesday, May 14, 2013  |  From Code-gen Templates

Hi I am using CSLA 4.3.10.0 in a multi tier application which uses WCF in IIS 6. The WCFconfig uses the standard 'wsHttpBinding' binding with no compression.


Recently whilst testing a new app I started seeing strange exceptions whenever the remote client attempted to save data to the app server. I traced the issue down to the default 8MB limit that IIS placec on transfers.


The remote client was actually parsing some csv and xml files to create a list of dirty objects, so it was fairly easy to creat a large set of dirty objects. I was able to work around the problem by  breaking up the upload into several smaller chunks, I noticed something that has raised my curiosity.


I never saw issues when retreiving data from the app server, even though the retrieved data  contained exactly the same objects that weretoo large to save (upload). Using Fidler I saw that the size of the uploaded data (dirty objects) was around 10x the size of the retrieved (downloaded) data (I undid the chunking for the tests).


 


Is there a reason for this discrepancy in size?


Is there any safe way to reduce the upload size?


 


Thanks


Kosta

Sunday, May 12, 2013  |  From Code-gen Templates

Maintenance release (update to Csla 4.3.14)


This release depends on CSLA .NET 4.3.14 and is also available on NuGet


Changes since CSLA .NET Contrib 4.3.13



  • Updated MEF call to only use SatisfyImportsOnce() to compose object
  • Upgraded rules and added NoDuplicates rule
  • NuGet packages dependency improvements

CSLA .NET Contrib 4.3.16 release notes and download

Saturday, May 11, 2013  |  From Code-gen Templates

Hello,


I have a business object for which I need to make some validations that involve several properties of the object and more data that I will need to read from the database. I'm using this object in an MVC application and I though that will be better to run this validation once, after all the related properties are set. In other objects with regular rules I usually suppress the rule checks, set all the properties and then call CheckRules before saving.


Should I use a Per-Type rule? I was looking the ebook "Creating business objects" and couldn't find any example or to much detail about per-type rules.


I would like somebody to point me in the right direction.


Thanks in advance.

Friday, May 10, 2013  |  From Code-gen Templates

I am using the CSLA 3.x framework.


This is my Unit Test method for the DataProtal Create method for one of our business objects.  Should I add anymore to it?


        /// <summary>
        ///A test for DataPortal_Create
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Cit.Library.dll")]
        public void DataPortal_CreateTest()
        {
            Person person = Person.GetPerson(false, 1);


            Cit_Accessor target = new Cit_Accessor();
            object criteria = new Cit_Accessor.Criteria(1, Person);


            target.DataPortal_Create(criteria);


            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

Friday, May 10, 2013  |  From Code-gen Templates

Hello,


I have a Silverlight CSLA project in VS2010 and it had been working with 4.3+ just fine. Then I upgraded to 4.5.10 when that was released using Nuget. Unknown at the time, the BeginSave method would fail to call the Saved event if an exception was thrown in the DataPortal_Update method. I didn't test any other scenarios. It used to be called in the 4.3.x version. The Csla.Xaml.ViewModel.BeginSave depends on the Saved event, so I suspect the new behavior is not expected.


Using the following code, the same differing results were generated when referencing the specified versions.


        private static void Main()
        {
            var obj = MyBusiness.Get(2);
            obj.Id = 3;
            obj.Saved += (o, e) => Debug.WriteLine("Saved");
            obj.BeginSave();
 
            Console.ReadKey();
        }
 
        [Serializable]
        public class MyBusiness : BusinessBase<MyBusiness>
        {
            public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
            public int Id
            {
                get { return GetProperty(IdProperty); }
                set { SetProperty(IdProperty, value); }
            }
 
            public static MyBusiness Get(int id)
            {
                return DataPortal.Fetch<MyBusiness>(id);
            }
 
            private void DataPortal_Fetch(int id)
            {
                using (BypassPropertyChecks)
                {
                    Id = id;
                }
            }
 
            protected override void DataPortal_Update()
            {
                throw new Exception("Failure");
            }
        }

Is there a bug in 4.5+ or is the behavior because I'm using version 4.5.10 in VS2010?

Friday, May 10, 2013  |  From Code-gen Templates

CSLA 4 version 4.5.30 is now available via nuget and the download page.


This version includes a number of bug fixes and some new features and is a recommended upgrade from 4.5.20.


Perhaps the biggest new feature is the ability to create classes that are invoked by the server-side data portal to simplify the use of IoC containers and DI as the data portal creates and interacts with root objects on the server. See the CustomActivator sample to see how this works.


Here's a list of changes:


https://github.com/MarimerLLC/csla/issues?milestone=4&state=closed

Friday, May 10, 2013  |  From Code-gen Templates

CSLA 4 version 4.3.14 is now available via nuget.

This version adds support for DateTimeOffset to SafeDataReader, addresses a MobileFormatter deserialization bug, and fixes an issue with warnings in CslaActionExtender.

As a result it is a relatively minor bug fix update from 4.3.13.


Change list:


https://github.com/MarimerLLC/csla/issues?milestone=5&state=closed

Thursday, May 09, 2013  |  From Code-gen Templates

I am trying to code a unit test for one of our business objects but I had a question about the way I am calling the dataprotal create method.  Here is a code snippets.  Should I not use a criteria class?  It passes in another business object that is inherited form the csla framework.


         [Serializable()]
        private class Criteria
        {
            public string RecordNo = string.Empty;
            public Person LoggedInPerson;
            public Criteria(string recordNo, Person LoggedInPerson)
            {
                this.RecordNo = recordNo;
                LoggedInPerson = LoggedInPerson;
            }
        }


        [RunLocal()]
        protected void DataPortal_Create(object criteria)
        {
            Criteria crit = (Criteria)criteria;


            //...


            ValidationRules.CheckRules();


        }

Thursday, May 09, 2013  |  From Code-gen Templates

Hi,


When i want to fetch record from CSLA it's giving error , we are using CSLA version 1 with window 7, 


please help me.


ExceptionSource: Csla: DataPortalException: DataPortal.Fetch failed ()
ExceptionDetail:
Csla.DataPortalException: DataPortal.Fetch failed () --->
System.NullReferenceException: Object reference not set to an instance
of an object.
at Csla.Server.CallMethodException..ctor(String
message, Exception ex) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Server\CallMethodException.cs:line
44
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info,
Object[] parameters) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\MethodCaller.cs:line 118
at
Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria,
DataPortalContext context) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Server\SimpleDataPortal.cs:line
109
--- End of inner exception stack trace ---
at
Csla.DataPortal.Fetch(Type objectType, Object criteria) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 192
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Tools\CSLA\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 140


 


Thanks,


Vivek

Wednesday, May 08, 2013  |  From Code-gen Templates

What is the best approach for implementing a per-property authorization rule that depends on the result of an async, lazy-loaded property?


Here's my suggestion:


 


[Serializable]


public sealed class Parent : BusinessBase<Parent>


{


public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(c => c.Name);


public string Name


{


get { return GetProperty(NameProperty); }


set { SetProperty(NameProperty, value); }


}



public static readonly PropertyInfo<ChildrenList> ChildrenProperty = RegisterProperty<ChildrenList>(c => c.Children, RelationshipTypes.Child | RelationshipTypes.LazyLoad);


public ChildrenList Children


{


get


{


if (!FieldManager.FieldExists(ChildrenProperty))


{


if (IsNew)


LoadProperty(ChildrenProperty, ChildrenList.NewList());


else


{


ChildrenList.GetListAsync(Id, (o, e) =>


{


if (e.Error != null)


throw e.Error;


LoadProperty(ChildrenProperty, e.Object);


OnPropertyChanged(ChildrenProperty);


});


return null;


}


}


return GetProperty(ChildrenProperty);


}


}



protected override void AddBusinessRules()


{


base.AddBusinessRules();


BusinessRules.AddRule(new Required(NameProperty));


BusinessRules.AddRule(new MaxLength(NameProperty, 255));


BusinessRules.AddRule(new CanWriteParentNameRule(AuthorizationActions.WriteProperty, NameProperty));


BusinessRules.AddRule(new Dependency(ChildrenProperty, NameProperty));


}


}


 


public class CanWriteParentNameRule : AuthorizationRule


{


public CanWriteParentNameRule(AuthorizationActions action, IMemberInfo element)


: base(action, element) { }


 


protected override void Execute(AuthorizationContext context)


{


var parent = context.Target as Parent;


 


if (parent != null && parent.Children != null)


context.HasPermission = (parent.Children.Count == 0);


else


context.HasPermission = false;


}


}


The binding of the name property causes the authorization rule to be evaluated which in turn triggers the async retrieval by accessing the Children property. The property returns null and we default HasPermission to false until we have the children.


When the Children property eventually returns, it raises OnPropertyChanged which in turn (via the Dependency business rule) causes the name property rules to be re-evaluated including the authorization rule. This time the authorization rule gets the children and sets HasPermission accordingly.


What do you think? Does this seem plausible?


Thanks in advance,



Joe

 

 Code-gen Templates News Feed 

 VS Templates News Feed 
Monday, May 20, 2013  |  From VS Templates

I'm having a problem during a SaveAsync method call in my Silverlight ViewModelBase. When my model 's graph gets too bloated, the "clone" and "undo" routines are taking a long time and the window gets stuck due to the synchronous process, if the user try to click on screen, the browser crashes. Consider putting the "clone" and "undo" routines in a task.


code: http://take.ms/VxPdtq

Monday, May 20, 2013  |  From VS Templates


I
have a rule in my children objects that uses some values from the parent
object. The rule must be executed when any of those values in the parent
changes. The rule also adds different error result messages depending of
certain conditions.


The options I have are:


1-Add the needed properties to
the child object and update its values every time the values in the parent
change using PropertyHasChanged. Those properties have to be loaded also for
every new child and when the children objects are being load from the database.


What I don't like about this
approach is to add properties to the child that don't really belong
there and all the code needed to load those properties.


 2-Create
a lambda rule in the child that uses the values from the parent through the
Parent property of the child object. Add some method in the child object to
call BusinessRules.CheckRules(MyProperty). That method will be used from the
parent object inside PropertyHasChanged to trigger the execution of the rule in
the children.


In
this option I don't know how to output different messages for the rule
depending of conditions inside the rule code. This is how I define the rule:


BusinessRules.AddRule<MyChild>(MyPropertyProperty,


o
=> {


                …rule code here using (MyParent)o.Parent


},
“Broken rule message”);


 


My
questions are:


Is
there a better solution for this?


If
not, how can I output different messages from the rule using the second option?


Thanks in advance.


Monday, May 20, 2013  |  From VS Templates

Guys, hope eveyone is well, but need some advice.


I have a class, and that class has children.  Each child is going to connect to a database, calculate some values and return.  At the moment this run in sync, so i loop through each child, connect to database, get result and move on to the next one.


This works fine, but i think running the code in async mode would benefit performance.


I seen this on microsoft site http://msdn.microsoft.com/en-us/library/3dasc8as(v=vs.80).aspx describing how to use a ThreadPool to execute async tasks, and the code waits until all the tasks are finished.  This sounds exactly like what i want to do, but i understand the Prinical objects etc are not copied over into other threads? I am using asp.net 4.0.


I havent done much async processing, and none where i need to carry the current prinical object.


I have seen that Csla has a backgroundWorker which does pass on the prinicipal values etc.  Is there a limit on the number of BackgroundWorkers i can create?  How would i wait for all backgroundworkers to complete?


Sorry i this is basic, but thought i would ask here as maybe someone else has had this problem as well

Monday, May 20, 2013  |  From VS Templates

Hello,


I am experiencing a problem with CSLA that didn't seem to be in the forums, until last week when someone else was experiencing the same problems as me. the post the question is in is marked with a suggested answer so this might be the reason why you have not seen it. however I am reposting it here in hope for a answer.


---------------------------------------------------------------------------------------------------------------------------------------------------------


 Original Post from  Cymro in forum post Error when pressing escape key on a filtered list bound datagridview


---------------------------------------------------------------------------------------------------------------------------------------------------------


I have tested this further and it appears that there are other issues around the CancelNew behaviour with a DataGridView.  The reason I was looking at this was because we are attempting to use a SortedBindingList and FilteredBindingList with a DynamicBindingListBase derived class.  The issue here is that when the list is Sorted (or filtered) the cancel new fails and leaves the invalid new item in the list.


I have tracked this down and found the issue but not a satisfactory resolution Tongue Tied


When a new row is added to a DataGridView the AddNew adds the object to the end of the list.  Even if the sorted is list is sorted it still goes at the end of the sorted list (which is what we want).


The issue is with the way that the DataGridView's DataBinding handles the cancelling. 


  1. The DataGridView calls CancelEdit on the child object through (IEditableObject.CancelEdit). 
  2. The changes get rolled back in the child object, but this has the side effect of raising OnUnknownPropertyChanged.
  3. PropertyChanged is handled by the parent BindingList and raises the IBindingList.ListChanged event with a ListChangeType of "Reset". 
  4. The SortedBindingList handles the ListChanged of the source list and calls DoSort, resorting all the items in the list (including the new item).  This is where the problem lies!!!
  5. The DataGridView then calls ICancelAddNew.CancelNew passing the last row index - but this is no longer where our item is, because it has been re-sorted into the middle of the list somewhere.

We do not see the effect of this issue in a BusinessBindingListBase because as part of the CancelEdit on the child, it calls to the parent list to remove it (when the EditLevel < EditLevelAdded) using IParent.RemoveChild(T child).  With a BusinessBindingListBase the implementation of this method removes the child, whereas with a DynamicBindingList does not.  Therefore, with a BusinessBindingListBase the new child is removed from the list before the CancelNew is even called (as part of step 2 above) which masks the issue with the CancelNew implementation of the SortedBindingList.


I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...


...suggests that this was thought about and decided this should not be done here.  And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.


Now the obvious "fix" is to have the DynamicBindingList remove the child as part of the IParent.RemoveChild implementation as follows...


    /// <summary>
/// This method is called by a child object when it
/// wants to be removed from the collection.
/// </summary>
/// <param name="child">The child object to remove.</param>
void Core.IEditableCollection.RemoveChild(Csla.Core.IEditableBusinessObject child)
{

      Remove((C)child);
}

I am unhappy with this "fix" for two reasons. Firstly, the original comment in the method...


      // do nothing, removal of a child is handled by
      // the RemoveItem override


...suggests that this was thought about and decided this should not be done here. And secondly because this just masks the real issue of the list getting re-sorted during the whole cancel process.  Does anyone have any thoughts?


---------------------------------------------------------------------------------------------------------------------------------------------------------


EDIT:


---------------------------------------------------------------------------------------------------------------------------------------------------------


Forgot to mention that I am using CSLA 4.0.1 and have also tried this on 4.2.something

Thursday, May 16, 2013  |  From VS Templates

Greetings:


I've a Silverlight application that needs to have a static class called "Settings".   This class will be a read only base class with about 2 dozen settings that should be available anywhere in the UI layer.  I'm not really sure where the best place to put that class might be ... that is, the best place to have the system make an async call to load up the settings.


Maybe Application_Startup?


Thoughts?

Thursday, May 16, 2013  |  From VS Templates

When I remove an item from a Dynamic List, Shouldn't the Update be called right away?  Here is the code from the View Model:


        private void OnDeleteSessionConfirmDialogClosed(IMessageBox messageBox)


        {


            if (messageBox.WasSelected(MessageBoxButtons.Yes))


            {


                Model.SessionList.Remove(Session);


            }


        }



I tried to save after it was removed, but the object was marked as busy and I couldn't apply edits:



        private void OnDeleteSessionConfirmDialogClosed(IMessageBox messageBox)


        {


            if (messageBox.WasSelected(MessageBoxButtons.Yes))


            {


                Model.SessionList.Remove(Session);


                Session.ApplyEdit();


                Session.BeginSave((o, e) =>


                    {


                        if (e.Error != null)


                        {


                            throw e.Error;


                        }                        


                    });


            }


        }



I don't think I need to do this as the Dynamic List should save automatically...Correct?  It does dissappear off the list in the datagrid, but it never disappears from the database...any help would be appreciated!  I am using Silverlight 5 with CSLA 4.3 (I believe).


Todd


 


Wednesday, May 15, 2013  |  From VS Templates

My use case scenario has defined these objects: Employee, User, Client.  My database is structured similar to inheritance where the base table is named Entity (id, displayname) with a one to one relationship to Person(entityId, firstname, lastname) with a one to one to Employee/User/Client(entityId, …) tables each containing their unique fields. An Entity can be one or all three of the use case objects.


I’ve created working business objects using code generation which creates an Entity with child property of Person with child properties for Employee, User and Client.  Everything is fairly straightforward in that binding is done using dot notation like Entity.Person.Employee.HireDate.  I’ve also created properties IsEmployee, IsClient, IsUser which checks for null on those properties.


In Rocky’s book he talks about responsibility driven design which seems to infer that my business objects should be redesigned like Employee(entityId, displayname, firstname, lastname, hiredate).  But this would create challenges when updating the database.  (I’m using ado for data access).


I haven’t run into any real problems with my current business object design, but in my desire to understand best practices I am curious if I should redo my business objects, perhaps learning and implementing EF as a my data access?

Wednesday, May 15, 2013  |  From VS Templates

My Dev team is having issues to incorporate Silverlight with Bxf in the CSLA 4.0 Factory Model, that has to call the wcf to fetch the data from database.

Has anybody faced similar issues? Any help in this regard is appreciated as we are hitting the wall at this time!

Wednesday, May 15, 2013  |  From VS Templates

Hello,


We are facing issues to incorporate Silverlight with Bxf in the Factory Model. That has to call the wcf to fetch the data from database. In case if you have some specific videos where in you have incorporated this entire process please suggest.


 

Tuesday, May 14, 2013  |  From VS Templates

Upgrade to Csla 4.5.30


This release depends on CSLA .NET 4.5.30 and is also available on NuGet


Changes since CSLA .NET Contrib version 4.3.16



  • Refactor CslaContrib.Caliburn.Micro to Csla 4.5.30
  • Refactor ObjectCaching to Csla 4.5.30
  • Updated Caliburn.Micro to 1.5.1
  • Removed Silverlight 4 projects
  • Added NET 4.5 projects
  • New project CslaContrib for Silverlight 5
  • New projects CslaContrib.MEF for Silverlight 5 and WinRT

CSLA .NET Contrib 4.5.30 release notes and download

Tuesday, May 14, 2013  |  From VS Templates

Hi I am using CSLA 4.3.10.0 in a multi tier application which uses WCF in IIS 6. The WCFconfig uses the standard 'wsHttpBinding' binding with no compression.


Recently whilst testing a new app I started seeing strange exceptions whenever the remote client attempted to save data to the app server. I traced the issue down to the default 8MB limit that IIS placec on transfers.


The remote client was actually parsing some csv and xml files to create a list of dirty objects, so it was fairly easy to creat a large set of dirty objects. I was able to work around the problem by  breaking up the upload into several smaller chunks, I noticed something that has raised my curiosity.


I never saw issues when retreiving data from the app server, even though the retrieved data  contained exactly the same objects that weretoo large to save (upload). Using Fidler I saw that the size of the uploaded data (dirty objects) was around 10x the size of the retrieved (downloaded) data (I undid the chunking for the tests).


 


Is there a reason for this discrepancy in size?


Is there any safe way to reduce the upload size?


 


Thanks


Kosta

Sunday, May 12, 2013  |  From VS Templates

Maintenance release (update to Csla 4.3.14)


This release depends on CSLA .NET 4.3.14 and is also available on NuGet


Changes since CSLA .NET Contrib 4.3.13



  • Updated MEF call to only use SatisfyImportsOnce() to compose object
  • Upgraded rules and added NoDuplicates rule
  • NuGet packages dependency improvements

CSLA .NET Contrib 4.3.16 release notes and download

Saturday, May 11, 2013  |  From VS Templates

Hello,


I have a business object for which I need to make some validations that involve several properties of the object and more data that I will need to read from the database. I'm using this object in an MVC application and I though that will be better to run this validation once, after all the related properties are set. In other objects with regular rules I usually suppress the rule checks, set all the properties and then call CheckRules before saving.


Should I use a Per-Type rule? I was looking the ebook "Creating business objects" and couldn't find any example or to much detail about per-type rules.


I would like somebody to point me in the right direction.


Thanks in advance.

Friday, May 10, 2013  |  From VS Templates

I am using the CSLA 3.x framework.


This is my Unit Test method for the DataProtal Create method for one of our business objects.  Should I add anymore to it?


        /// <summary>
        ///A test for DataPortal_Create
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Cit.Library.dll")]
        public void DataPortal_CreateTest()
        {
            Person person = Person.GetPerson(false, 1);


            Cit_Accessor target = new Cit_Accessor();
            object criteria = new Cit_Accessor.Criteria(1, Person);


            target.DataPortal_Create(criteria);


            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

Friday, May 10, 2013  |  From VS Templates

Hello,


I have a Silverlight CSLA project in VS2010 and it had been working with 4.3+ just fine. Then I upgraded to 4.5.10 when that was released using Nuget. Unknown at the time, the BeginSave method would fail to call the Saved event if an exception was thrown in the DataPortal_Update method. I didn't test any other scenarios. It used to be called in the 4.3.x version. The Csla.Xaml.ViewModel.BeginSave depends on the Saved event, so I suspect the new behavior is not expected.


Using the following code, the same differing results were generated when referencing the specified versions.


        private static void Main()
        {
            var obj = MyBusiness.Get(2);
            obj.Id = 3;
            obj.Saved += (o, e) => Debug.WriteLine("Saved");
            obj.BeginSave();
 
            Console.ReadKey();
        }
 
        [Serializable]
        public class MyBusiness : BusinessBase<MyBusiness>
        {
            public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
            public int Id
            {
                get { return GetProperty(IdProperty); }
                set { SetProperty(IdProperty, value); }
            }
 
            public static MyBusiness Get(int id)
            {
                return DataPortal.Fetch<MyBusiness>(id);
            }
 
            private void DataPortal_Fetch(int id)
            {
                using (BypassPropertyChecks)
                {
                    Id = id;
                }
            }
 
            protected override void DataPortal_Update()
            {
                throw new Exception("Failure");
            }
        }

Is there a bug in 4.5+ or is the behavior because I'm using version 4.5.10 in VS2010?

Friday, May 10, 2013  |  From VS Templates

CSLA 4 version 4.5.30 is now available via nuget and the download page.


This version includes a number of bug fixes and some new features and is a recommended upgrade from 4.5.20.


Perhaps the biggest new feature is the ability to create classes that are invoked by the server-side data portal to simplify the use of IoC containers and DI as the data portal creates and interacts with root objects on the server. See the CustomActivator sample to see how this works.


Here's a list of changes:


https://github.com/MarimerLLC/csla/issues?milestone=4&state=closed

Friday, May 10, 2013  |  From VS Templates

CSLA 4 version 4.3.14 is now available via nuget.

This version adds support for DateTimeOffset to SafeDataReader, addresses a MobileFormatter deserialization bug, and fixes an issue with warnings in CslaActionExtender.

As a result it is a relatively minor bug fix update from 4.3.13.


Change list:


https://github.com/MarimerLLC/csla/issues?milestone=5&state=closed

Thursday, May 09, 2013  |  From VS Templates

I am trying to code a unit test for one of our business objects but I had a question about the way I am calling the dataprotal create method.  Here is a code snippets.  Should I not use a criteria class?  It passes in another business object that is inherited form the csla framework.


         [Serializable()]
        private class Criteria
        {
            public string RecordNo = string.Empty;
            public Person LoggedInPerson;
            public Criteria(string recordNo, Person LoggedInPerson)
            {
                this.RecordNo = recordNo;
                LoggedInPerson = LoggedInPerson;
            }
        }


        [RunLocal()]
        protected void DataPortal_Create(object criteria)
        {
            Criteria crit = (Criteria)criteria;


            //...


            ValidationRules.CheckRules();


        }

Thursday, May 09, 2013  |  From VS Templates

Hi,


When i want to fetch record from CSLA it's giving error , we are using CSLA version 1 with window 7, 


please help me.


ExceptionSource: Csla: DataPortalException: DataPortal.Fetch failed ()
ExceptionDetail:
Csla.DataPortalException: DataPortal.Fetch failed () --->
System.NullReferenceException: Object reference not set to an instance
of an object.
at Csla.Server.CallMethodException..ctor(String
message, Exception ex) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Server\CallMethodException.cs:line
44
at Csla.MethodCaller.CallMethod(Object obj, MethodInfo info,
Object[] parameters) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\MethodCaller.cs:line 118
at
Csla.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria,
DataPortalContext context) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Server\SimpleDataPortal.cs:line
109
--- End of inner exception stack trace ---
at
Csla.DataPortal.Fetch(Type objectType, Object criteria) in
C:\Tools\CSLA\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 192
at Csla.DataPortal.Fetch[T](Object criteria) in C:\Tools\CSLA\csla20cs\Csla\DataPortal\Client\DataPortal.cs:line 140


 


Thanks,


Vivek

Wednesday, May 08, 2013  |  From VS Templates

What is the best approach for implementing a per-property authorization rule that depends on the result of an async, lazy-loaded property?


Here's my suggestion:


 


[Serializable]


public sealed class Parent : BusinessBase<Parent>


{


public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(c => c.Name);


public string Name


{


get { return GetProperty(NameProperty); }


set { SetProperty(NameProperty, value); }


}



public static readonly PropertyInfo<ChildrenList> ChildrenProperty = RegisterProperty<ChildrenList>(c => c.Children, RelationshipTypes.Child | RelationshipTypes.LazyLoad);


public ChildrenList Children


{


get


{


if (!FieldManager.FieldExists(ChildrenProperty))


{


if (IsNew)


LoadProperty(ChildrenProperty, ChildrenList.NewList());


else


{


ChildrenList.GetListAsync(Id, (o, e) =>


{


if (e.Error != null)


throw e.Error;


LoadProperty(ChildrenProperty, e.Object);


OnPropertyChanged(ChildrenProperty);


});


return null;


}


}


return GetProperty(ChildrenProperty);


}


}



protected override void AddBusinessRules()


{


base.AddBusinessRules();


BusinessRules.AddRule(new Required(NameProperty));


BusinessRules.AddRule(new MaxLength(NameProperty, 255));


BusinessRules.AddRule(new CanWriteParentNameRule(AuthorizationActions.WriteProperty, NameProperty));


BusinessRules.AddRule(new Dependency(ChildrenProperty, NameProperty));


}


}


 


public class CanWriteParentNameRule : AuthorizationRule


{


public CanWriteParentNameRule(AuthorizationActions action, IMemberInfo element)


: base(action, element) { }


 


protected override void Execute(AuthorizationContext context)


{


var parent = context.Target as Parent;


 


if (parent != null && parent.Children != null)


context.HasPermission = (parent.Children.Count == 0);


else


context.HasPermission = false;


}


}


The binding of the name property causes the authorization rule to be evaluated which in turn triggers the async retrieval by accessing the Children property. The property returns null and we default HasPermission to false until we have the children.


When the Children property eventually returns, it raises OnPropertyChanged which in turn (via the Dependency business rule) causes the name property rules to be re-evaluated including the authorization rule. This time the authorization rule gets the children and sets HasPermission accordingly.


What do you think? Does this seem plausible?


Thanks in advance,



Joe

 

 VS Templates News Feed 

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

Comments

No comments yet.