Problems encountered during the use of nhib.pdf and some fragmented knowledge after constant solution:
1. Express:
After Express declares a variable, it can save a lamda expression, Express exp = (o => o. fieldname), which can dynamically combine the fields to be queried.
Code:
Expression <Func <Gx. Model. Author, bool> where1, where2;
If (CityId! = 0)
{
// StrCity = "and other_City =" + CityId;
Where1 = o => o. OtherCity = CityId;
}
Else where1 = o => o. AuthorId! = Null;
If (Types)
{
// StrPhoto = "and Photo1 is not null ";
Where2 = o => o. Photo1! = Null;
}
Else where2 = o => o. AuthorId! = Null;
Var list1 = new Author (). CreateQueryOver (). Where (where1)
. Where (where2)
. OrderBy (o => o. AuthorId). Desc
. Take (NO)
. List <Gx. Model. Author> (); // obtain the latest member.
Ii. Sorting after table connection.
IList <Gx. Model. MessageBoard> MessBoard = (from m in iq2
// From t in m. MessageBoards
//. OrderByDescending (o => o. MessageBoards. Select (oo => oo. MBMessageDate ))
// From t in m. Orders
Join m2 in iq
On m. AuthorId equals m2.Author. AuthorId into m3
From t in m3
Orderby t. AuthorID
Select new Gx. Model. MessageBoard {Mb_id = t. Mb_id, FromID = t. FromID, Realname = t. FromID! = 0? T. Author. RealName: t. Realname, MBIP = t. FromID! = 0? T. Author. OtherAddress: t. MBIP, MBMessage = t. MBMessage, MBMessageDate = t. MBMessageDate, Author = t. Author })
//. Orderby (o => o. AuthorID)
. Take (Count)
. ToList <Gx. Model. MessageBoard> ();
An error (Invalid Path) will be reported when sorting is like the red font above ).
Solution:
MessBoard = MessBoard .. Orderby (o => o. AuthorID). ToList ();
3. nhib.pdf provides the same functions as case when:
Condition: An IQueryable and linq query must be returned during data access (convenient ).
Select new Gx. Model. MessageBoard {Mb_id = t. Mb_id, FromID = t. FromID, Realname = t. FromID! = 0? T. Author. RealName: t. Realname, MBIP = t. FromID! = 0? T. Author. OtherAddress: t. MBIP, MBMessage = t. MBMessage, MBMessageDate = t. MBMessageDate, Author = t. Author })
The above is just a few scattered essays. If there are any mistakes, criticize and correct them.