我有三个班,他们都有一个属性Date.我想编写一个泛型类来返回一个日期的所有记录.现在的问题是:如何使用泛型类型T编写lambda表达式?
代码简单如下(我不会编译,因为"r.Date"不起作用,但它是我想要实现的效果)
Class GenericService<T>: IGenericService<T> where T:class
{
...
readonly IGenericRepository<T> _genericRepository;
public IEnumerable<T> GetRecordList(DateTime date)
{
var query=_genericRepository.FindBy(r=>r.Date=date);
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
此致,Léona
我的团队现在正在为我们公司开发一个名为"trdocs"的wordpress项目,我们在本地安装了wordpress并安装了大量的插件,我们有自己的数据库等.现在我们想将这个现有的wordpress项目放在Windows Azure上.我们不仅要迁移项目,还要迁移SQL azure上的数据库.就个人而言,我遵循了如何使用Windows Azure SDK for PHP WordPress脚手架部署WordPress ,这是一个很好的帖子,但它是在Azure上部署一个全新的wordpress.有没有任何想法?
期待答案......
此致,Leona
我有4张桌子:
table1
id1,
fk_tbl2 //this is the foreign key to the "id" in table2
table2
id2,
fk_tbl3 //this is the foreign key to the "id" in table3
table3
id3,
fk_tbl4 //this is the foreign key to the "id" in table4
table4
id4,
name
Run Code Online (Sandbox Code Playgroud)
我想进行多表连接,当用户输入"id4"时,我可以在"table1"中获得记录列表.
如何在C#中编写连接?谢谢.
我有一个我想要调用的泛型方法,但它抛出以下异常:
你调用的对象是空的.
事实上,GetMethod(...)等于null.但是我无法找到我做错的地方,因为我在另一个班级里有一个非常相似的功能.这是简单的代码:
Class DatabaseSyncronizor
{
...
internal void SyncronizeAll()
{
for(int i=0;i<MyList.Count();i++)
{
Type type=Type.GetType(MyModelClass);
typeof(DatabaseSyncronizor).GetMethod("Synchronize",BindingFlags.NonPublic|BindingFlags.Instance).MakeGenericMethod(type).Invoke(this, null);
}
}
private void Syncronize<T>() where T :class,IDate
{
IGenericService<T> service = new GenericService<T>(new UnitOfWorkFactory(_connectionString));
...
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
此致,Léona
我有一些表:
table1:
id1
fk_tb2 // this is the fk to table2
table2:
id2
fk_tb3 //this is the fk to table3
table3:
id3
name3
Run Code Online (Sandbox Code Playgroud)
现在我想返回一个像:id1 fk_tb2 name3的表
谁知道怎么做?谢谢
问候,