Click here to Skip to main content
15,895,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# program on windows server 2003 Pin
Mycroft Holmes21-Apr-14 22:58
professionalMycroft Holmes21-Apr-14 22:58 
GeneralRe: C# program on windows server 2003 Pin
LeonXjm4-May-14 17:38
LeonXjm4-May-14 17:38 
QuestionGIS coordinates (spherical mercator) to screen coordinates? Pin
SledgeHammer0121-Apr-14 12:42
SledgeHammer0121-Apr-14 12:42 
AnswerRe: GIS coordinates (spherical mercator) to screen coordinates? Pin
Bernhard Hiller21-Apr-14 21:38
Bernhard Hiller21-Apr-14 21:38 
Questioncustom webcontrol designer problems Pin
Nico Haegens21-Apr-14 7:41
professionalNico Haegens21-Apr-14 7:41 
QuestionBy using the web services/WCF of Amazon (and other retailers) my client can upload there products on Amazon (and other sites) in bulk. Pin
Santosh K. Tripathi20-Apr-14 23:08
professionalSantosh K. Tripathi20-Apr-14 23:08 
SuggestionRe: By using the web services/WCF of Amazon (and other retailers) my client can upload there products on Amazon (and other sites) in bulk. Pin
Santosh K. Tripathi27-Apr-14 21:00
professionalSantosh K. Tripathi27-Apr-14 21:00 
QuestionC# Linq To SQL Dynamic Where Clause Pin
Kevin Marois20-Apr-14 11:39
professionalKevin Marois20-Apr-14 11:39 
I will have a couple of methods that are called to mark records as deleted:

public DeleteByAddressIdResponse DeleteByAddressId(int Id)
{
    Func<ClientAddressEntity, bool> whereClause = ca => ca.AddressId == Id;

    return deleteClientAddresses<DeleteByAddressIdResponse >(whereClause);
}


public DeleteByAddressTypeIdResponse DeleteByAddressTypeId(int Id)
{
    Func<ClientAddressEntity, bool> whereClause = ca => ca.AddressTypeId == Id;

    return deleteClientAddresses<DeleteByAddressTypeIdResponse >(whereClause);
}


public DeleteByClientIdResponse DeleteByClientId(int Id)
{
    Func<ClientAddressEntity, bool> whereClause = ca => ca.ClientId == Id;

    return deleteClientAddresses<DeleteByClientIdResponse >(whereClause);
}


I'm trying to create a where clause for a Linq To Sql query. I'm not sure how to apply there where clause.

private T deleteClientAddresses<T>(Func<ClientAddressEntity, bool> whereClause) where T : _ResponseBase
{
    var response = (T)Activator.CreateInstance(typeof(T));

    using (var dc = getDataContext())
    {
        // ============>  HOW DO I APPLY THERE WHERE CLAUSE HERE??? <=============
        var entities = (from ca in dc.ClientAddresses select ca);

        foreach (var entity in entities)
        {
            var deleteAddressResponse = DeleteAddress(entity.AddressId);

            if (deleteAddressResponse.Result == Result.Success)
            {
                entity.IsDeleted = true;

                try
                {
                    dc.SubmitChanges();
                }
                catch (Exception e)
                {
                    response.Exception = e;
                    break;
                }
            }
            else
            {
                response.Exception = deleteAddressResponse.Exception;
            }
        }
    }

    return response;
}


Thanks
If it's not broken, fix it until it is

AnswerRe: C# Linq To SQL Dynamic Where Clause Pin
Richard Deeming22-Apr-14 2:07
mveRichard Deeming22-Apr-14 2:07 
GeneralRe: C# Linq To SQL Dynamic Where Clause Pin
Kevin Marois22-Apr-14 5:41
professionalKevin Marois22-Apr-14 5:41 
GeneralRe: C# Linq To SQL Dynamic Where Clause Pin
Richard Deeming22-Apr-14 6:32
mveRichard Deeming22-Apr-14 6:32 
GeneralRe: C# Linq To SQL Dynamic Where Clause Pin
Kevin Marois22-Apr-14 6:37
professionalKevin Marois22-Apr-14 6:37 
GeneralRe: C# Linq To SQL Dynamic Where Clause Pin
Richard Deeming22-Apr-14 6:42
mveRichard Deeming22-Apr-14 6:42 
GeneralRe: C# Linq To SQL Dynamic Where Clause Pin
Kevin Marois22-Apr-14 6:44
professionalKevin Marois22-Apr-14 6:44 
Questionknapsack Pin
Member 1076234920-Apr-14 9:52
Member 1076234920-Apr-14 9:52 
AnswerRe: knapsack Pin
Pete O'Hanlon20-Apr-14 11:46
mvePete O'Hanlon20-Apr-14 11:46 
AnswerRe: knapsack Pin
OriginalGriff20-Apr-14 20:49
mveOriginalGriff20-Apr-14 20:49 
GeneralRe: knapsack Pin
Pete O'Hanlon20-Apr-14 21:57
mvePete O'Hanlon20-Apr-14 21:57 
GeneralRe: knapsack Pin
OriginalGriff20-Apr-14 22:04
mveOriginalGriff20-Apr-14 22:04 
QuestionRe: knapsack Pin
ZurdoDev21-Apr-14 9:37
professionalZurdoDev21-Apr-14 9:37 
Questionknap sack Pin
Member 1076234920-Apr-14 9:43
Member 1076234920-Apr-14 9:43 
AnswerRe: knap sack Pin
Pete O'Hanlon20-Apr-14 9:50
mvePete O'Hanlon20-Apr-14 9:50 
GeneralRe: knap sack Pin
Manfred Rudolf Bihy20-Apr-14 10:22
professionalManfred Rudolf Bihy20-Apr-14 10:22 
GeneralRe: knap sack Pin
Wes Aday20-Apr-14 10:31
professionalWes Aday20-Apr-14 10:31 
AnswerRe: knap sack Pin
OriginalGriff20-Apr-14 20:48
mveOriginalGriff20-Apr-14 20:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.