小编Enr*_*ani的帖子

在C#中处理多参数查询的模式或最佳实践

我在编写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)

c# parameters design-patterns

1
推荐指数
1
解决办法
745
查看次数

标签 统计

c# ×1

design-patterns ×1

parameters ×1