Skip to main content

3 table join in lambda expresion

       SWAEntities Db = new SWAEntities();
            Expression<Func<Wallet, bool>> whereClause = AdminBuildDynamicWhereClauseTransit(Db, columns, createdby);
            var result =Db.SW_Wallet.Join(Db.NLP_RegistrationSW, w=>w.CreatedBy , t=>t.ID , (w,t)=>new {wallet=w, trader=t })
                .Join(Db.SW_OrgPdLink , x=>x.trader.ID , pd=>pd.OrgId ,(x,pd)=>new {Pdacc=pd, x.wallet , x.trader })
               .Where(m=>m.wallet.CreatedBy == createdby && (m.wallet.Isdeleted == false ||m.wallet.Isdeleted == null))
                .Select(m => new
                {
                    m.wallet.Status,
                    m.wallet.CreatedDate,
                    m.wallet.TransactionDate,
                    m.wallet.Amount,
                    m.wallet.Currency,
                    m.wallet.BankName,
                    m.wallet.Remarks,
                    m.wallet.Documents,
                    m.trader.FirstName,
                    m.trader.LastName,
                    m.Pdacc.PDAAccountId

                   
                 })
   
             
               

                .OrderBy(sortBy, sortDir)
                .Skip(skip)
                .Take(take)
                .AsEnumerable()
                .Select(m =>
                new Wallet
                {
                    TransactionDate = m.TransactionDate,
                    Status = m.Status,
                    CreatedDate = m.CreatedDate?.ToString("dd/MM/yyyy"),
                    Amount = m.Amount,
                    Currency = m.Currency,
                    bankName=m.BankName,
                    Remark=m.Remarks,
                    Document=m.Documents,
                    TraderFname=m.FirstName,
                    TraderLname=m.LastName
                })
                .ToList();
              totalResultsCount = result.AsQueryable().Count();
              filteredResultsCount = result.AsQueryable().Where(whereClause).Count();
              result = result.AsQueryable().Where(whereClause).ToList();
            if (take == -1)
            {
                take = filteredResultsCount;
            }
            return result;

Popular posts from this blog

Add barcode on pdf

using System; using System.IO; using System.Drawing; using ZXing; using iTextSharp.text; using iTextSharp.text.pdf; using System.Drawing; using System.Web.UI.WebControls; namespace PDFBarcode {     public partial class WebForm1 : System.Web.UI.Page     {         byte[] byteImage;         protected void Page_Load(object sender, EventArgs e)         {         }         protected void btnDownload_Click(object sender, EventArgs e)         {                       Random r = new Random();             string fileName = r.Next().ToString();             string filenameext = fileName + ".pdf";             GenerateBarcode(fileName);             string Sourcepath = Server.MapPath("~/SavedF...

Dynamic Menu in asp.net using Listview

 1.    public DataTable LoadMenu()         {             MenuBal MenuBal = new MenuBal();             DataSet ds = this.GetData(0);             PopulateMenu(ds);             return ds.Tables[2];         }     private DataSet GetData(int parentMenuId)         {             MenuBal objmenu = new MenuBal();             string Mode = "";             if (Session["Mode"] != null)             {                 Mode = Session["Mode"].ToString();             }             DataSet ds = objmenu.GetData(parentMenuId, Convert.ToInt32(SessionHelper.CurrentUserId), Mode, SessionHelper...