AspnetProfileCommands Partial Class

This command factory creates static partial classes that generate parameterized database commands to the ASP.NET database, in this case the “Profile” table. This partial class could be extended to include your own queries if you desired.

[csharp]
//*****************************************************************************
// This file is part of the data access layer example to the ASP.NET 2.0 provider database
// This file was written by Adam Buenz [WSS MVP] of ARB Security Solutions, LLC
// http://www.sharepointsecurity.com
//
// This file and its parts is free for re-distribution, for use in both free
// and commercial applications, however this header must remain intact for legal
// use. The data access layer example is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//*****************************************************************************
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Aspnet.Provider.Datalayer.Commands
{
///

/// A command factory class for AspnetProfile objects.
///

internal static partial class AspnetProfileCommands
{
///

/// Finds all AspnetProfile objects with a certain Propertynames value.
///

/// The Propertynames value (‘*’ can be used as a wildcard). /// An IDbCommand that finds all AspnetProfile objects with a certain Propertynames value.
public static IDbCommand FindByPropertynames(string propertynames)
{
SqlCommand cmd;
if (propertynames == null)
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [PropertyNames] is null”);
else
{
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [PropertyNames] like @propertynames”);
cmd.Parameters.AddWithValue(“@propertynames”, propertynames.Replace(“*”, “%”));
}
return cmd;
}

///

/// Finds all AspnetProfile objects with a certain Propertyvaluesstring value.
///

/// The Propertyvaluesstring value (‘*’ can be used as a wildcard). /// An IDbCommand that finds all AspnetProfile objects with a certain Propertyvaluesstring value.
public static IDbCommand FindByPropertyvaluesstring(string propertyvaluesstring)
{
SqlCommand cmd;
if (propertyvaluesstring == null)
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [PropertyValuesString] is null”);
else
{
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [PropertyValuesString] like @propertyvaluesstring”);
cmd.Parameters.AddWithValue(“@propertyvaluesstring”, propertyvaluesstring.Replace(“*”, “%”));
}
return cmd;
}

///

/// Finds all AspnetProfile objects with a certain Propertyvaluesbinary value.
///

/// The Propertyvaluesbinary value. /// An IDbCommand that finds all AspnetProfile objects with a certain Propertyvaluesbinary value.
public static IDbCommand FindByPropertyvaluesbinary(byte[] propertyvaluesbinary)
{
SqlCommand cmd;
if (propertyvaluesbinary == null)
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [PropertyValuesBinary] is null”);
else
{
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [PropertyValuesBinary] like @propertyvaluesbinary”);
cmd.Parameters.AddWithValue(“@propertyvaluesbinary”, propertyvaluesbinary);
}
return cmd;
}

///

/// Finds all AspnetProfile objects with a certain Lastupdateddate value.
///

/// The Lastupdateddate value. /// An IDbCommand that finds all AspnetProfile objects with a certain Lastupdateddate value.
public static IDbCommand FindByLastupdateddate(DateTime lastupdateddate)
{
SqlCommand cmd;
cmd = new SqlCommand(“select * from [dbo].[aspnet_Profile] where [LastUpdatedDate] = @lastupdateddate”);
cmd.Parameters.AddWithValue(“@lastupdateddate”, lastupdateddate);
return cmd;
}

}
}

[/csharp]

Share

Leave a Reply

Your email address will not be published. Required fields are marked *