Need a good LinqDataSource example in code, not markup

Does anyone have a good example of how to fully create LinqDataSource code? I don't need help writing a LINQ query. I just need help setting up the code stream. The reason I want to do this in code is because the complexity of the query I need goes beyond the capabilities of the LinqDataSource wizard.

+3
source share
2 answers

Ok, can you indicate what you mean by customization? This is an example of how to create LinqDataSourceand prepare it for use:

LinqDataSource source = new LinqDataSource();
source.ContextTypeName = "MyDataContext";
source.TableName = "MyTable";
source.Select = "new (Id As MyId, Name As MyName)";
source.Where = "Id > 1";

, :

LinqDataSource source = new LinqDataSource();
source.ContextTypeName = "MyDataContext";
source.Selecting += source_Selecting;
...
void source_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    e.Result = from number in numbers where number > 1 select number;
}
+3

SharePoint SPGridView, .

0

Source: https://habr.com/ru/post/1703661/


All Articles