我在编写winforms或wpf应用程序以对数据库执行查询时总是采用的方法如下:
设计一个带有多个控件的接口,以将参数传递给我的查询类
使用Linq或Entity Framework作为数据源,使用查询的字段,属性和方法构建"DataAccess"类.
Managing the events generated by the controls, to pass parameters and select wich method to use to retrieve data.
Example from the DataAccess class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyApplication
{
public class DataAccess
{
public LinqDataContext db = new LinqDataContext();
#region Private Fields
#region Properties(Constructors)
#region Methods
// Sample method
public List<DataAccess> Mymethod(string valoredata, int esenzione,
string valorebatch)
{
if (esenzione == 0)
{
return (from elementi in db.IndexTables
from elementi2 …Run Code Online (Sandbox Code Playgroud)