Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model.GetTable<T>().Where(t => here equality );
- public static T GetById(Guid id)
- {
- Type entType = typeof(T);
- if (!CheckTable(entType)) {
- throw new TypeLoadException(string.Format(
- "{0} is not Table Entity, has no attribute Table", entType.FullName));
- }
- string property = GetPrimaryKeyName(entType).Name;
- ParameterExpression cs;
- var lambda = Expression.Lambda<Func<Personal, bool>>(
- Expression.Equal(
- Expression.Property(
- cs = Expression.Parameter(typeof(T), "p"),
- entType.GetProperty(property).GetGetMethod()
- ),
- Expression.Constant(id),
- false,
- typeof(Guid).GetMethod("Equals")
- ), new ParameterExpression[] { cs }
- );
- return Connection.Model.GetTable<T>().Single(lambda);
- }
Add Comment
Please, Sign In to add comment