Wednesday, June 26, 2019

Export To Excel and Other In Jquery

1. Code of html

@{
    Layout = null;
}


<!DOCTYPE html>
<html>
<head>
    <title>jQuery TableExport Basic Demo</title> 
</head>
<body>
 
    <div class="container">
        <h1>jQuery TableExport Basic Demo</h1>
        <table id="tbl1" class="table table-striped table-bordered" data-name="cool-table">
            <caption class="btn-toolbar bottom">
                <button data-fileblob="{&quot;data&quot;:[[&quot;Rank&quot;,&quot;Country&quot;,&quot;Population&quot;,&quot;% of world population&quot;,&quot;Date&quot;],[&quot;1&quot;,&quot;China&quot;,&quot;1,370,570,000&quot;,&quot;18.9%&quot;,&quot;June 24, 2015&quot;],[&quot;2&quot;,&quot;India&quot;,&quot;1,273,140,000&quot;,&quot;17.6%&quot;,&quot;June 24, 2015&quot;],[&quot;3&quot;,&quot;United States&quot;,&quot;321,268,000&quot;,&quot;4.43%&quot;,&quot;June 24, 2015&quot;],[&quot;4&quot;,&quot;Indonesia&quot;,&quot;255,461,700&quot;,&quot;3.52%&quot;,&quot;July 1, 2015&quot;],[&quot;5&quot;,&quot;Brazil&quot;,&quot;204,503,000&quot;,&quot;2.82%&quot;,&quot;June 24, 2015&quot;],[&quot;6&quot;,&quot;Pakistan&quot;,&quot;190,156,000&quot;,&quot;2.62%&quot;,&quot;June 24, 2015&quot;]],&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&quot;,&quot;fileExtension&quot;:&quot;.xlsx&quot;}" class="btn btn-default xlsx">
                    Export to xlsx
                </button>
                @*<button data-fileblob="{&quot;data&quot;:[[&quot;Rank&quot;,&quot;Country&quot;,&quot;Population&quot;,&quot;% of world population&quot;,&quot;Date&quot;],[&quot;1&quot;,&quot;China&quot;,&quot;1,370,570,000&quot;,&quot;18.9%&quot;,&quot;June 24, 2015&quot;],[&quot;2&quot;,&quot;India&quot;,&quot;1,273,140,000&quot;,&quot;17.6%&quot;,&quot;June 24, 2015&quot;],[&quot;3&quot;,&quot;United States&quot;,&quot;321,268,000&quot;,&quot;4.43%&quot;,&quot;June 24, 2015&quot;],[&quot;4&quot;,&quot;Indonesia&quot;,&quot;255,461,700&quot;,&quot;3.52%&quot;,&quot;July 1, 2015&quot;],[&quot;5&quot;,&quot;Brazil&quot;,&quot;204,503,000&quot;,&quot;2.82%&quot;,&quot;June 24, 2015&quot;],[&quot;6&quot;,&quot;Pakistan&quot;,&quot;190,156,000&quot;,&quot;2.62%&quot;,&quot;June 24, 2015&quot;]],&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;application/vnd.ms-excel&quot;,&quot;fileExtension&quot;:&quot;.xls&quot;}" class="btn btn-default xls">
                    Export to xls
                </button>
                <button data-fileblob="{&quot;data&quot;:&quot;\&quot;Rank\&quot;,\&quot;Country\&quot;,\&quot;Population\&quot;,\&quot;% of world population\&quot;,\&quot;Date\&quot;\r\n\&quot;1\&quot;,\&quot;China\&quot;,\&quot;1,370,570,000\&quot;,\&quot;18.9%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;2\&quot;,\&quot;India\&quot;,\&quot;1,273,140,000\&quot;,\&quot;17.6%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;3\&quot;,\&quot;United States\&quot;,\&quot;321,268,000\&quot;,\&quot;4.43%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;4\&quot;,\&quot;Indonesia\&quot;,\&quot;255,461,700\&quot;,\&quot;3.52%\&quot;,\&quot;July 1, 2015\&quot;\r\n\&quot;5\&quot;,\&quot;Brazil\&quot;,\&quot;204,503,000\&quot;,\&quot;2.82%\&quot;,\&quot;June 24, 2015\&quot;\r\n\&quot;6\&quot;,\&quot;Pakistan\&quot;,\&quot;190,156,000\&quot;,\&quot;2.62%\&quot;,\&quot;June 24, 2015\&quot;&quot;,&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;text/csv&quot;,&quot;fileExtension&quot;:&quot;.csv&quot;}" class="btn btn-default csv">
                    Export to csv
                </button>
                <button data-fileblob="{&quot;data&quot;:&quot;Rank  Country  Population  % of world population  Date\r\n1  China  1,370,570,000  18.9%  June 24, 2015\r\n2  India  1,273,140,000  17.6%  June 24, 2015\r\n3  United States  321,268,000  4.43%  June 24, 2015\r\n4  Indonesia  255,461,700  3.52%  July 1, 2015\r\n5  Brazil  204,503,000  2.82%  June 24, 2015\r\n6  Pakistan  190,156,000  2.62%  June 24, 2015&quot;,&quot;fileName&quot;:&quot;myDownload&quot;,&quot;mimeType&quot;:&quot;text/plain&quot;,&quot;fileExtension&quot;:&quot;.txt&quot;}" class="btn btn-default txt">
                    Export to txt
                </button>*@
            </caption>
            <thead>
                <tr>
                    <th>Rank</th>
                    <th>Country</th>
                    <th>Population</th>
                    <th>% of world population</th>
                    <th>Date</th>
                    <th>Rank</th>
                    <th>Country</th>
                    <th>Population</th>
                    <th>% of world population</th>
                    <th>Date</th>
                    <th>Rank</th>
                    <th>Country</th>
                    <th>Population</th>
                    <th>% of world population</th>
                    <th>Date</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>
                <tr>
                    <td>1</td>
                    <td>China</td>
                    <td>1,370,570,000</td>
                    <td>18.9%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>
                    <td>2</td>
                    <td>India</td>
                    <td>1,273,140,000</td>
                    <td>17.6%</td>
                    <td>June 24, 2015</td>

                </tr>

            </tbody>
        </table>

        <script src="/csjs/jquery-1.12.4.min.js"></script>
        <script src="/csjs/FileSaver.min.js"></script>
        <script src="/csjs/Blob.min.js"></script>
        <script src="/csjs/xls.core.min.js"></script>
        <script src="/csjs/tableexport.js"></script>
        <script>
            //$("#tbl1").tableExport({ formats: ["xlsx", "xls", "csv", "txt"], });
            $("#tbl1").tableExport({ formats: ["xlsx"] });
        </script>   

    </div> 
</body>
</html>


2.   Js File Link
https://drive.google.com/file/d/1cSpc7ZBUgsBXXURL3AwZD8W1C__XvWUR/view?usp=sharing

JS Files Link to download


3. Export To Excel and CSV but Import CSV only into DataTable

Monday, June 24, 2019

Set Default Value in property in c# or Set Value in property in c#

1. Using Constructor

class Person 
{
    public Person()
    {
        Name = "Default Name";
    }
    public string Name { get; set; }
}
2. Normal

private string name = "Default Name";
public string Name 
{
    get 
    {
        return name;
    }
    set
    {
        name = value;
    }
}

Action Filter in MVC

1.


     
    public class change_all_form_authorization : ActionFilterAttribute
    { 
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string controller_ = filterContext.RouteData.Values["controller"].ToString();
            string action_ = filterContext.RouteData.Values["action"].ToString();

            if (HttpContext.Current.Session["change_all_form_authorization"] == null)
            {
                HttpContext.Current.Session["change_all_form_authorization"] = "/" + controller_ + "/" + action_;
                //HttpContext.Current.Session["change_all_form_authorization"] = "authorize-form-password";
                filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new
                {
                    Controller = "Login",
                    Action = "auth_form_permi"
                }));
                //HttpContext.Current.Response.Redirect("/Login/auth_form_permi");
                return;
            }
            HttpContext.Current.Session["change_all_form_authorization"] = null;
            base.OnActionExecuting(filterContext);
        }
    }

Wednesday, June 19, 2019

Deploy or Publish

1. Local Hosting for Publish

2. Publish With Folder Option

3. Hosts File Path for Local hosting

4. Hosts Default File for local host,  Hash (#) Sign is for commented

5. Hosts File Change for Local Hosting


Async In MVC

1.  Async In MVC V start at

Web Api

1. Web Api Routing with Route , Passing parameter with [FromUri] or [FromBody]

Tuesday, June 18, 2019

Pass Checked Unchecked in checkbox mvc razor

1. Pass Checked Unchecked in checkbox in mvc razor
    or Pass Checked Unchecked in checkbox in mvc
    or Pass Checked Unchecked in checkbox in razor


<tbody>
    @for (int i = 0; i < dl.Count; i++)
    {
        <tr>
            <td>@(i + 1)<input type="hidden" name="forms_list[@(i)].formid" value="@fl[i].formid"></td>
            <td>@dl[i].form_name </td>
            <td><input type="checkbox" name="forms_list[@(i)].view_" value="true" @(dl[i].view_ == true ? "checked" : "unchecked")></td>
            <td><input type="checkbox" name="forms_list[@(i)].add_" value="true" @(dl[i].add_ == true ? "checked" : "unchecked") ></td>
            <td><input type="checkbox" name="forms_list[@(i)].edit_" value="true" @(dl[i].edit_ == true ? "checked" : "unchecked") ></td>
            <td><input type="checkbox" name="forms_list[@(i)].del_" value="true" @(dl[i].del_ == true ? "checked" : "unchecked") ></td>
        </tr>
    }
</tbody>

1. Pass disabled in mvc razor

<div class="col-1">
    <div class="form-group mb-3">
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="Feb" name="Feb" checked="@Model.Feb" value="true" @(Model.Feb == true ? "disabled" : "")>
            <label class="custom-control-label" for="Feb">Feb</label>
        </div>
    </div>
</div>
<div class="col-1">
    <div class="form-group mb-3">
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="Mar" name="Mar" checked="@Model.Mar" @(Model.Mar == true ? "disabled" : "") value="true">
            <label class="custom-control-label" for="Mar">Mar</label>
        </div>
    </div>
</div>

Dependency Injection in MVC5

1. Dependency Injection in MVC5

Unit Test in MVC

1. Unit Test in MVC

MVC Cycles


Custome Model Binder

1. Custome Model Binder binds header value like

Search in Jquery

1. Html

    <div class="col-md-4">
        <div class="row">
            <div class="col-md-12">
                <input type="search" id="id_forms" placeholder="Search" class="col-md-12" />
            </div>
        </div>
        <table class="table" id="tbl_form" width="100%">
            <thead>
                <tr>
                    <th>Srno</th>
                    <th>Forms</th>
                </tr>
            </thead>
            <tbody>
                @for (int i = 0; i < fl.Count; i++)
                {
                    <tr>
                        <td>@(i + 1)<input type="hidden" value="@fl[i].formid"></td>
                        <td>@fl[i].form_name</td>
                    </tr>
                }
            </tbody>
        </table>
    </div>

2. JQuery

<script src="~/scripts/jquery-3.4.1.min.js"></script>
<script>
    $(document).ready(function () {      
        $("#id_forms").on("keyup", function () {
            var value_ = $(this).val().toLowerCase();
            $("#tbl_form tbody tr").filter(function () {
                $(this).toggle($(this).text().toLowerCase().indexOf(value_) > -1)
            })
        })
        
    })
</script>



Fill Model List or Fill Class List with join and left join class in Linq

1.Class

    [MetadataType(typeof(auth_model_mas_meta))]
    public partial class auth_model_mas
    {
        public string model_id { get; set; }
        public string model_name { get; set; }
        public Nullable<bool> model_st { get; set; }
    }

   [MetadataType(typeof(auth_form_mas_meta))]
    public partial class auth_form_mas
    {
        public string formid { get; set; }
        public string form_name { get; set; }
        public string model_id { get; set; }
    }
 
    [MetadataType(typeof(auth_form_mas_meta))]
    public partial class auth_form_mas_
    {
        public string formid { get; set; }
        public string form_name { get; set; }
        public string model_id { get; set; }
        public string model_name { get; set; }
    }


2. Linq Query > fill class list auth_form_mas_ with join linq query

        public async Task<ActionResult> Index()
        {
            var result = (from x in db.auth_form_mas
                          join y in db.auth_model_mas on x.model_id equals y.model_id
                          where 1==1
                          orderby x.form_name
                          select (new auth_form_mas_()
                          {
                              formid = x.formid,
                              form_name = x.form_name,
                              model_id = x.model_id,
                              model_name = y.model_name
                          })).ToList();
            List<auth_form_mas_> dl = result;
            return View(dl);
            //return View(await db.auth_form_mas.ToListAsync());
        }

3. Linq Query > fill class list auth_form_mas_ with left join

        public async Task<ActionResult> Index()
        {
            var result = (from x in db.auth_form_mas
                          join y in db.auth_model_mas on x.model_id equals y.model_id 
                          into ys from y in ys.DefaultIfEmpty()
                          where 1==1
                          orderby x.form_name
                          select (new auth_form_mas_()
                          {
                              formid = x.formid,
                              form_name = x.form_name,
                              model_id = x.model_id,
                              model_name = y.model_name
                          })).ToList();
            List<auth_form_mas_> dl = result;
            return View(dl);
        }


4. Another Example Linq Query > fill class list auth_form_mas_ with join linq query


            var data = from x in db.auth_profile
                       join p in db.auth_profile_master on x.profileid equals p.profileid
                       join f in db.auth_form_mas on x.formid equals f.formid
                       join u in db.auth_user on x.userid equals u.userid
                       where 1 == 1 && x.userid == d.userid
                       orderby f.form_name
                       select (new auth_profile_()
                       {
                           Srno = x.Srno,
                           userid = x.userid,
                           user_name = u.name,
                           username = u.username,
                           formid = x.formid,
                           form_name = f.form_name,
                           profileid = p.profile_name,
                           profile_name = p.profile_name,
                           add_ = x.add_,
                           view_ = x.view_,
                           edit_ = x.edit_,
                           del_ = x.del_,
                           Password = x.Password
                       });

            ViewBag.auth_profile_List = data.ToList();



5. Multiple Join in linq or Multi column join linq


var data = from x in db.v_Client
                           join y in db.City_Mas on x.city_code equals y.city_code
                           into ys
                           from y in ys.DefaultIfEmpty()
                           join z in db.State_Mas on x.state_code equals z.state_code
                           into zs
                           from z in zs.DefaultIfEmpty()
                           join t in db.Thana_Mas on x.th_code equals t.th_code
                           into ts
                           from t in ts.DefaultIfEmpty()
                           join c in db.Court_Mas on x.cou_code equals c.cou_code
                           into cs
                           from c in cs.DefaultIfEmpty()
                           join h in db.v_current_tbl_history on new { f1 = x.ad_code, f2 = x.cl_code } equals new { f1 = h.ad_code, f2 = h.cl_code }
                           into hs
                           from h in hs.DefaultIfEmpty()
                           join u in db.auth_user on x.cl_code equals u.userid
                           into us
                           from u in us.DefaultIfEmpty()

                           where (d.srno == 0 || d.srno == x.srno)
                           && (d.ad_code == null || d.ad_code == x.ad_code)
                           && (d.cl_code == null || d.cl_code == x.cl_code)
                           && (d.cl_name == null || x.cl_name.StartsWith(d.cl_name))
                           && (d.cou_code == null || d.cou_code == x.cou_code)
                           && (d.cou_name == null || c.cou_name.StartsWith(d.cou_name))
                           && (d.th_code == null || d.th_code == x.th_code)
                           && (d.th_name == null || t.th_name.StartsWith(d.cou_name))
                           && (d.city_code == null || x.city_code == d.city_code)
                           && (d.state_code == null || x.state_code == d.state_code)
                           && (d.city_name == null || y.city_name.StartsWith(d.city_name))
                           && (d.state_name == null || z.state_name.StartsWith(d.state_name))
                           && (d.skip_date == null || h.cl_nextdate < d.skip_date)
                           orderby x.cl_edate descending
                           select (new v_Client_()
                           {
                               srno = x.srno,
                               ad_code = x.ad_code,
                               cl_code = x.cl_code,
                               cl_id = x.cl_id,
                               cl_eno = x.cl_eno,
                               cl_edate = x.cl_edate,
                               cl_casetype = x.cl_casetype,
                               cl_name = x.cl_name,
                               cl_address = x.cl_address,
                               state_code = x.state_code,
                               city_code = x.city_code,
                               th_code = x.th_code,
                               cou_code = x.cou_code,
                               cl_contactno = x.cl_contactno,
                               cl_father = x.cl_father,
                               cl_sectionno = x.cl_sectionno,
                               cl_fees = x.cl_fees,
                               cl_paid = x.cl_paid,
                               cl_balance = x.cl_balance,
                               cl_assu1 = x.cl_assu1,
                               cl_assu2 = x.cl_assu2,
                               cl_assu3 = x.cl_assu3,
                               cl_assu4 = x.cl_assu4,
                               cl_assu5 = x.cl_assu5,
                               cl_assu1c = x.cl_assu1c,
                               cl_assu2c = x.cl_assu2c,
                               cl_assu3c = x.cl_assu3c,
                               cl_assu4c = x.cl_assu4c,
                               cl_assu5c = x.cl_assu5c,
                               cl_paricular = x.cl_paricular,
                               cl_client = x.cl_client,
                               cl_assu1add = x.cl_assu1add,
                               cl_assu1city = x.cl_assu1city,
                               cl_assu1fath = x.cl_assu1fath,
                               cnr_no = x.cnr_no,
                               parokar_name = x.parokar_name,
                               par_number = x.par_number,
                               par_address = x.par_address,
                               cl_status = x.cl_status,
                               edate = x.edate,
                               e_id = x.e_id,
                               udate = x.udate,
                               u_id = x.u_id,

                               city_name = y.city_name,
                               state_name = z.state_name,
                               cou_name = c.cou_name,
                               th_name = t.th_name,

                               hsrno = h.srno,
                               cl_nextdate = h.cl_nextdate,
                               cl_pastdate = h.cl_pastdate,
                               present_status = h.present_status,
                               future_status = h.future_status,
                               cl_remark = h.cl_remark,
                               jugment = h.jugment,

                               username = u.username,
                               passwd = u.passwd

                           });

                var dt = data.ToList();



Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)