Παρουσίαση με Ετικέτες

Xaf tip # 6 Linq your Session queries
17 Σεπτεμβρίου 09 04:07 μμ | tolisss | 0 σχόλια   
Pretty silent these days eh? I am working on a big refactoring on DictionaryDifference and have not much time to blog. But have another tip for my Xaf Tips series today maybe not strictly Xaf but is an XPO tip that you can use with your Xaf applications . The Problem Suppose your are a strongly typed fun like me or you want to use linq to query objects inside a transaction. In order linq to be used with XPO DevExpress provides XPQuery<T> class but unfortunately this do not support transactions. So the following test fails var work = new UnitOfWork(); new User(work){UserName = "Sam" }; User firstOrDefault = new XPQuery<User>(work).Where(user => user.UserName == "Sam" ).FirstOrDefault(); Assert.IsNotNull(firstOrDefault); The solution

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , ,
CodeSmith templates for Xaf
30 Ιουνίου 09 11:39 πμ | tolisss | 0 σχόλια   
Yes I know that is not the best practice. When using Xaf or Xpo you should first design your objects and let the framework create the database schema based on objects metadata (attributes). But there are many cases that the database is already design and you can not change it. What about those projects? Are you going to say to your customer that you do not want that project? Are you going to sit down and write all classes by hand? The best solution on this is to use some Template engine like Codesmith to create the initial implementation for you and then you can change them to meet your needs. You can also find a freeware version of Codesmith here Devexpress also has a persistent class generation Util which ca be invoked from the add new item form    

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , , ,
Validation Rule: At least one property is required
03 Ιουνίου 09 01:33 πμ | tolisss | 0 σχόλια   
Today i stump again upon the same problem . I wanted to throw a validation exception only if both of my properties do not have value. So lets create a validation rule for this one. More info on how we create custom validation rules can be found here Validation Module Since we are talking about multiple property values i think we should go with an attribute that is applied to a class and not to a property. Ok first we have to define that both our RuleBaseAttribute and RuleBaseProperties derived classes will implement . public interface IRuleRequiredForAtLeast1PropertyProperties { string MessageTemplateMustNotBeEmpty { get; set; } string Delimiters { get; set; } string TargetProperties { get; set; } } ok that looks nice lets explain what we have here for a bit.

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , ,
Automatic properties for Xpo
02 Ιουνίου 09 05:23 πμ | tolisss | 0 σχόλια   
  The problem Xpo in order to support transactions implements some special kind of property setters like private string lastName; public string LastName { get { return lastName; } set { string oldValue = lastName; if (oldValue == value) return; lastName = value; OnChanged("Name", oldValue, value); } } Or a little more elegant like private string lastName; public string LastName { get { return lastName; } set { SetPropertyValue("LastName", ref lastName, value); } } Imagine you want to Design a fairly simple model like Customer –> Orders. A Customer should have LastName, FilrstName, Age and Orders as properties and Order only an Amount property. Using the above approach one could write the following code to describe the above model.

Διαβάστε περισσότερα »

Δημοσίευση στην κατηγορία: , , , ,

Search

Go

Το Ιστολόγιο

Ιστορικό Δημοσιεύσεων

Συνδρομές