本文整理汇总了C#中Customer.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.GetType方法的具体用法?C# Customer.GetType怎么用?C# Customer.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public void Main(string[] args)
{
var config = new ConfigurationBuilder(@"C:\VSProjects\Precisionsoft\Decidify\trunk\Decidify.UI")
.AddJsonFile("config.json");
var mongoProvider = new MongoDbAuditStoreProvider()
.WithConfiguration(config.Build())
.Start();
using (var myDbContext = new MyDBContext(mongoProvider))
{
myDbContext.Database.EnsureDeleted();
myDbContext.Database.EnsureCreated();
var customer = new Customer()
{
FirstName = "TestFirstName",
LastName = "TEstLAstNAme"
};
myDbContext.Customers.Add(customer);
var auditablePropCount =
customer.GetType()
.GetProperties()
.Count(p => !p.GetCustomAttributes(typeof (DoNotAudit), true).Any());
var nonAuditablePropCount =
customer.GetType()
.GetProperties()
.Count(p => p.GetCustomAttributes(typeof(DoNotAudit), true).Any());
myDbContext.SaveChanges("Test User");
Console.WriteLine($"Added object with {auditablePropCount} auditable properties and {nonAuditablePropCount} non-auditable properties." );
var auditLogs = myDbContext.GetAuditLogs()?.ToList();
Console.WriteLine($"Audit log contains {auditLogs?.Count()} entries.");
//foreach (var auditLog in myDbContext.GetAuditLogs())
//{
// Console.WriteLine($"AuditLogId:{auditLog.AuditLogId} TableName:{auditLog.TableName} ColumnName:{auditLog.ColumnName} OriginalValue:{auditLog.OriginalValue} NewValue:{auditLog.NewValue} EventDateTime:{auditLog.EventDateTime}");
//}
//if (auditLogs.Count() == auditablePropCount)
// Console.WriteLine("Test succeeded.");
//else
// throw new Exception("Something is wrong.");
Console.Read();
myDbContext.Database.EnsureDeleted();
}
}
示例2: CustomerView
public CustomerView(Customer model)
{
Mapper.CreateMap<Customer, CustomerView>();
Mapper.Map<Customer, CustomerView>(model, this);
this.created = model.created.ToString().Replace('T', ' ');
this.updated = model.updated.ToString().Replace('T', ' ');
this.type = model.GetType().BaseType.Name;
}
示例3: DeleteCustomers
public void DeleteCustomers(List<Customer> customers)
{
Customer cliente = new Customer();
cliente.GetType();
Type tt = typeof(Customer);
foreach (PropertyInfo pp in tt.GetProperties())
{
//pp.
}
}
示例4: UpdateCustomer
public void UpdateCustomer(Customer customer)
{
NorthwindEntities model = new NorthwindEntities();
var customerToBeUpdated = (from cust in model.Customers
where cust.CustomerID == customer.CustomerID
select cust).FirstOrDefault();
foreach (PropertyInfo property in customer.GetType().GetProperties())
{
customerToBeUpdated.GetType().GetProperty(property.Name).
SetValue(customerToBeUpdated, property.GetValue(customer, new object[] { }), new object[] {});
}
model.SaveChanges();
}
示例5: CreateEntry
private ODataEntry CreateEntry(Customer customer, DataServiceOperationContext operationContext)
{
if (customer == null) return null;
var entry = new ODataEntry();
entry.EditLink = new Uri(operationContext.AbsoluteServiceUri, "Customers(" + customer.ID + ")");
entry.Id = entry.EditLink;
var metadataProvider = (IDataServiceMetadataProvider)operationContext.GetService(typeof(IDataServiceMetadataProvider));
ResourceType rt;
metadataProvider.TryResolveResourceType(customer.GetType().FullName, out rt);
entry.Properties = GetProperties(customer, rt);
entry.TypeName = rt.FullName;
return entry;
}
示例6: ProcessOrder
public decimal ProcessOrder(Customer customer, IEnumerable<Product> products)
{
// do some processing of order
decimal orderTotal = products.Sum(p => p.Price);
Type customerType = customer.GetType();
if (customerType == typeof(Employee))
{
orderTotal -= orderTotal * 0.15m;
}
else if (customerType == typeof(NonEmployee))
{
orderTotal -= orderTotal * 0.05m;
}
return orderTotal;
}
示例7: AddCustomer
public void AddCustomer(Customer customer)
{
Customers.Add(customer);
NorthwindEntities model = new NorthwindEntities();
NorthwindDAL.Customer customerToBeInserted = new NorthwindDAL.Customer();
var customerID = (from cust in model.Customers
where cust.CustomerID == customer.CustomerID
select cust).FirstOrDefault();
if (customerID != null)
{ return; }
foreach (PropertyInfo property in customer.GetType().GetProperties())
{
customerToBeInserted.GetType().GetProperty(property.Name).
SetValue(customerToBeInserted, property.GetValue(customer, new object[] { }), new object[] { });
}
model.Customers.AddObject(customerToBeInserted);
model.SaveChanges();
}