using System;
using Csla;
using Csla.Serialization;
using ShouWang.Framework;
using System.Linq;
using ShouWang.Framework.BusinessClass;
using System.ComponentModel;
#if !SILVERLIGHT
using ShouWang.Data;
using System.Data;
#endif
namespace ShouWang.ZSOA
{
[Serializable]
public class ReplyConfig :BaseBusiness<ReplyConfig>
{
#region Business Methods
public static PropertyInfo<string> UserIPProperty = RegisterProperty<string>(c => c.UserIP);
public string UserIP
{
get { return GetProperty(UserIPProperty); }
set { SetProperty(UserIPProperty, value); }
}
public static PropertyInfo<SmartDate> AnswerTimeProperty = RegisterProperty<SmartDate>(c => c.AnswerTime, "Name", new SmartDate());
public string AnswerTime
{
get { return GetPropertyConvert<SmartDate, string>(AnswerTimeProperty); }
set { SetPropertyConvert<SmartDate, string>(AnswerTimeProperty, value); }
}
public static PropertyInfo<SmartDate> AdddataProperty = RegisterProperty<SmartDate>(c => c.Adddata, "Name", new SmartDate());
public string Adddata
{
get { return GetPropertyConvert<SmartDate, string>(AdddataProperty); }
set { SetPropertyConvert<SmartDate, string>(AdddataProperty, value); }
}
public static PropertyInfo<string> ContentProperty = RegisterProperty<string>(c => c.Content);
public string Content
{
get { return GetProperty(ContentProperty); }
set { SetProperty(ContentProperty, value); }
}
public static PropertyInfo<string> UserNameProperty = RegisterProperty<string>(c => c.UserName);
public string UserName
{
get { return GetProperty(UserNameProperty); }
set { SetProperty(UserNameProperty, value); }
}
public static PropertyInfo<string> UserIdProperty = RegisterProperty<string>(c => c.UserId);
public string UserId
{
get { return GetProperty(UserIdProperty); }
set { SetProperty(UserIdProperty, value); }
}
public static PropertyInfo<int> ParentIdProperty = RegisterProperty<int>(c => c.ParentId);
public int ParentId
{
get { return GetProperty(ParentIdProperty); }
set { SetProperty(ParentIdProperty, value); }
} public static PropertyInfo<int> ReplyCountProperty = RegisterProperty<int>(c => c.ReplyCount);
public int ReplyCount
{
get { return GetProperty(ReplyCountProperty); }
set { SetProperty(ReplyCountProperty, value); }
}
public static PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
public int Id
{
get { return GetProperty(IdProperty); }
set { SetProperty(IdProperty, value); }
}
#endregion
//public static void DoSearch(int intId, EventHandler<DataPortalResult<ReplyConfig>> handler)
//{
// DataPortal.BeginFetch<ReplyConfig>(intId, handler);
//}
#if SILVERLIGHT
public ReplyConfig()
{
ModuleId = "ZSOA_060";
ModuleName = "批复";
}
#else
private ReplyConfig()
{
ModuleId = "ZSOA_060";
ModuleName = "批复";
}
#endif
#if !SILVERLIGHT
#endif
}
}
我需要返回一个集合 集合的代码如下
using System;
using Csla;
using Csla.Serialization;
using ShouWang.Framework;
using System.Linq;
using ShouWang.Framework.BusinessClass;
#if !SILVERLIGHT
using ShouWang.Data;
using System.Data;
#endif
namespace ShouWang.ZSOA
{
[Serializable]
public class ReplyConfigList:BaseReadOnlyList<ReplyConfigList,ReplyConfig>
{
public static ReplyConfigList Query(int intId)
{
return DataPortal.Fetch<ReplyConfigList>(new SingleCriteria<ReplyConfigList, int>(intId));
}
#if !SILVERLIGHT
private void DataPortal_Fetch(int intId)
{
RaiseListChangedEvents = false;
IsReadOnly = false;
using (var ctx = ObjectContextManager.GetObjectContext<ZSOAEntities>())
{
var data = from A in ctx.ObjectContext.ReplyDetail
where A.ParentId == intId
select A;
int i = data.Count();
data.ForEach(t =>
{
//Add();
//就是这个地方我该怎么写 Add 里面 我要怎样才能添加
});
}
IsReadOnly = true;
RaiseListChangedEvents = true;
}
#endif
}
}
ObservableCollection<ReplyConfig> replyConfigList = new ObservableCollection<ReplyConfig>();
然后把 replyConfigList 赋给你的视图类 View 的 DataContext 成员,在 View 的 xaml 中写绑定表达式:
ItemsSource="{Binding Path=DataContext}"
然后你再定义你的列:
<GridViewColumn Header="时间" DisplayMemberBinding="{Binding Path=AnswerTime
}"/>