LINQ Query

495

Solutions

371

Contributors

Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages, although ports exist for Java, PHP, JavaScript and ActionScript. LINQ extends the language by the addition of query expressions, which are akin to SQL statements, and can be used to conveniently extract and process data from arrays, enumerable classes, XML documents, relational databases, and third-party data sources.

Share tech news, updates, or what's on your mind.

Sign up to Post

Below codes is to call Twilio API and get the sms historical conversation for one phone no. However, it takes over 15 seconds and the total records is actually just 5 conversation.

Have any experts worked with Twilio in the past and know another way to get SMS conversation in a faster mode?
Thanks,



TwilioClient.Init(accountSid, authToken);
            var messages2 = MessageResource.Read().Where(x => x.From.ToString() == fromPhoneNo);
            var messages3 = MessageResource.Read().Where(y => y.To == fromPhoneNo);
            var all = messages2.Concat(messages3).OrderByDescending(z => z.DateCreated);

Open in new window

0
[Webinar] How Hackers Steal Your Credentials
LVL 8
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

i have an scenario where i have to compare  live data from the database to the data in the customer file that we get every night and send only the changes between the two.

i am trying to create a join in LINQ where i need to join two columns, customer and status to that of the file.
if its the same customer and same status but all the other columns are different then write it as changed customer but if its the same customer and different status then i would like to update that customer record to a 4 which means removed customer. this is my linq code i am not sure how to do a join on multiple columns and how to do an update.

i would like to join customers and status on the below code

     DataTable tblSamebutotherchanges = (from r in FirstDataTable.AsEnumerable() 
                                                join s in SecondDataTable.AsEnumerable()
                                                on r.Field<string>("Customer") equals s.Field<string>("Customer")
                                                where r.Field<string>("STATUS").Trim() == s.Field<string>("STATUS").Trim() || r.Field<string>("Name").Trim() != s.Field<string>("Name").Trim() || r.Field<string>("ADDRESS").ToUpper().Trim() != s.Field<string>("ADDRESS").ToUpper().Trim() || r.Field<string>("ADDRESS 2").Trim() != s.Field<string>("ADDRESS 2").Trim() || r.Field<string>("CITY").ToUpper().Trim() != s.Field<string>("CITY").ToUpper().Trim() || r.Field<string>("STATE").Trim() != 

Open in new window

0
Hi Experts,
I need help with a 'System.ObjectDisposedException' error I am getting in my C#.net Mvc.Net application.
I have posted my code below.

Code where I retrieve data from the database
private static List<InboundReject> getRejects()
{
    using (Utilities.RejectLetter db = new Utilities.RejectLetter())
    {

        var _rejectLetter = from m in db.InboundRejects
                            join c in db.InboundManifests on m.InboundManifestID equals c.InboundManifestID
                            where m.LetterPrintDate == null
                            select m;

        return _rejectLetter.ToList();
    }
}

Open in new window


Code where I attempt to use the data retrieved from the database
NOTE: the last statement reject.InboundManifest.Market.ToString() is what is throwing the error.
List<InboundReject> Rejects = getRejects();
foreach (InboundReject reject in Rejects)
{
    generateLetters(
        reject.DCN.ToString(), 
        reject.Description.ToString(),
        reject.BillingProviderName.ToString(),
        reject.BillingProviderAddress.ToString(),
        reject.BillingProviderCity.ToString(),
        reject.BillingProviderState.ToString(),
        reject.BillingProviderZip.ToString(),
        reject.EDOS.ToString(),
        reject.TotalCharge.ToString(),
        reject.PatientLName.ToString(),
        reject.PatientFName.ToString(),
        reject.InsuredID.ToString(),
        reject.PatientAccountNumber.ToString(),
        reject.InboundManifest.Market.ToString());
}

Open in new window


Thank you in advance for your help,
mrotor
0
I'm getting some odd and inconsistent behavior from Entity Framework 6 / MVC 5 when including related records in a Linq query

Example:
var timecards = db.Timecards.Include("Purchases.Authorizations").ToList();

Open in new window


That grabs a list of time cards, and normally includes a related parent item and a list of related records (authorization numbers, in this case). This has worked every time until recently.

Now that list will SOMETIMES include the related records and sometimes it won't. There's no error message, it just has null values for those properties. The data is there in the database, and foreign keys are all intact.

You can run this again 5 seconds later and a different random subset of the list will have missing info.

Any idea why? Or how I can force this to work every time?
0
I need to get a random record from  sql database with Linq query in entity.
0
I trying to create a query similar to below.    

I want a list of opportunities by FKVCCenterID.  But I have to go right back to the organisation and then to the VCCentres get this.

VCCentres have Organisations
Organisations have Opportunities


This query works except it returns an aynonmous type instead of the type i want which is tblOpportunities

  var opportunities = (from org in _ctx.tblVCCenterOrganisations
                join vc in _ctx.tblOrganisations on org.FKOrganisationID equals vc.OrganisationID
                join ops in _ctx.tblOpportunities on org.FKOrganisationID equals ops.FKOrganisationID
                select new
                {
                    FKVCCenterID = org.FKVCCenterID,
                    OpportunityID = ops.OpportunityID,
                    Title = ops.Title,

                }
            ).Where(x => x.FKVCCenterID == 999).Take(take).Skip(skip);


If i specify the type "select new tblOpportunity()" the where clause breaks because the tblOpportunity does not contain the FKVCCenterID
  var opportunities = (from org in _ctx.tblVCCenterOrganisations
                join vc in _ctx.tblOrganisations on org.FKOrganisationID equals vc.OrganisationID
                join ops in _ctx.tblOpportunities on org.FKOrganisationID equals ops.FKOrganisationID
                select new tblOpportunity()
                {
                    OpportunityID = ops.OpportunityID,
                    Title = ops.Title,

    …
0

LINQ Query

495

Solutions

371

Contributors

Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages, although ports exist for Java, PHP, JavaScript and ActionScript. LINQ extends the language by the addition of query expressions, which are akin to SQL statements, and can be used to conveniently extract and process data from arrays, enumerable classes, XML documents, relational databases, and third-party data sources.

Top Experts In
LINQ Query
<
Monthly
>