How to use SQL LIKE [duplicate]

0

I am trying to put together a string that makes a filter to compare only one piece of a numbering. I tried to make a resource and I looked for several ways to do it and so far I could not.

using (NFSeDataContext context = new NFSeDataContext(ConnNFSe))
            {
                context.Connection.Open();

                var _s = (from p in context.NFS_Parcelas
                          join q in context.NFBP_CONCILIACAO_BRASPAGs on p.NFPA_CD_UNIDADE equals q.NFBP_CD_UNIDADE
                          where 
                            _idUnidade == p.NFPA_CD_UNIDADE
                           & _dtCred == p.NFPA_DT_MOVIMENTO
                           & p.NFPA_TX_COMPLEMENTO.Contains(q.NFBP_TID)

                          select new
                          {
                              p.NFPA_CD_UNIDADE,
                              q.NFBP_DT_FLUXO_CAIXA,
                              q.NFBP_COD_AUTORIZACAO,
                              q.NFBP_TID,
                              q.NFBP_VL_BRUTO_TRANSACAO,
                              q.NFBP_VL_LIQUIDO_TRANSACAO,
                              p.NFPA_NR_PARCELA,
                              q.NFBP_BANDEIRA
                          }).Distinct().ToList();


                context.Connection.Close();
                grvConciliacaoBraspag.DataSource = _s;
                grvConciliacaoBraspag.DataBind();


            } 

In this code, q.NFBP_TID displays, for example, an excerpt that represents the value:

104349099700D67C2012

The p.NFPA_TX_COMPLEMENT displays a section that displays the value:

VISA13010000104349099700D67C2012BP 1201

If you compare the two results:

-> 104349099700D67C2012

VISA13010000 -> 104349099700D67C2012 BP 1201

I'm pretty sure that this Contains check I made is wrong. This was one of the examples of an attempt. I just posted the code to get a sense of my doubt.

    
asked by anonymous 26.02.2016 / 18:22

1 answer

2

Try using SqlMethods.Like instead of contains.

SqlMethods.Like(p.NFPA_TX_COMPLEMENTO, "%" + q.NFBP_TID + "%")
    
26.02.2016 / 19:19