ffrom p in products
join c in categories on p.CategoryId equals c.Id into g
from c in g.DefaultIfEmpty()
select new
{
CategoryTitle = c == null ? string.Empty : c.Title,
ProductTitle = p.Title
};
My Web Development Blog
вівторок, 8 листопада 2011 р.
LINQ: left join
середа, 26 жовтня 2011 р.
Oracle: disable a trigger in an stored procedure
execute immediate 'ALTER TRIGGER tr_name DISABLE'; ... execute immediate 'ALTER TRIGGER tr_name ENABLE';
четвер, 20 жовтня 2011 р.
понеділок, 17 жовтня 2011 р.
ExtJS: delay/buffer event
listeners: {
keyup: {
fn: function () {
//...
},
delay: 500 //buffer: 500
}
}
четвер, 13 жовтня 2011 р.
EF 4.1 Code-First: generate model
private void WriteEdm()
{
var settings = new XmlWriterSettings();
settings.Indent = true;
using (var ctx = new WebEntities())
{
using (var writer = XmlWriter.Create(Server.MapPath(@"Model.edmx"), settings))
{
EdmxWriter.WriteEdmx(ctx, writer);
}
}
}
середа, 12 жовтня 2011 р.
EF 4.1 Code-First: remove all conventions
protected override void OnModelCreating(DbModelBuilder db)
{
var types = typeof(IConvention).Assembly.GetTypes()
.Where(x => x.IsClass && !x.IsAbstract && typeof(IConvention).IsAssignableFrom(x))
.ToList();
var remove = typeof(ConventionsConfiguration).GetMethod("Remove");
types.ForEach(x => remove.MakeGenericMethod(x).Invoke(db.Conventions, null));
}
Полный список аннотаций, поддерживаемый в EF 4.1
KeyAttribute
StringLengthAttribute
MaxLengthAttribute
ConcurrencyCheckAttribute
RequiredAttribute
TimestampAttribute
ComplexTypeAttribute
ColumnAttribute
Атрибут свойства для указания имени столбца, ординарного типа и типа данных
TableAttribute
Атрибут класса для указания имени таблицы и схемы
InversePropertyAttribute
Атрибут свойства навигации для указания свойства, которое представляет другой конец связи
ForeignKeyAttribute
Placed on a navigation property to specify the property that represents the foreign key of the relationship
DatabaseGeneratedAttribute
Атрибут свойства для указания того, как база данных будет вычислять значение поля (Identity, Computed or None)
NotMappedAttribute
Атрибут свойства или класса для его исключения из базы данных
source
Підписатися на:
Коментарі (Atom)